Advertisement
Guest User

Untitled

a guest
Sep 15th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     jQuery.ajaxSetup({
  2.             cache: false,
  3.             dataType: 'json',
  4.             headers: {'X-Requested-With': 'XMLHttpRequest'},
  5.             success: function(payload) {
  6.                 if (payload.snippets) {
  7.                     for (var i in payload.snippets) {
  8.                         $('#' + i).html(payload.snippets[i]);
  9.                     }
  10.                 } else {
  11.                     if (payload.redirect) {
  12.                         window.location.href = payload.redirect;
  13.                     }
  14.                 }
  15.             }
  16.         });
  17.  
  18.         $(document).ajaxStart(function() {
  19.             // Akce po spusteni ajaxu (Napr zobrazeni spinner obrazku)
  20.         });
  21.         $(document).ajaxStop(function() {
  22.         // Akce po ukonceni ajaxu (Napr skryti snipenner obrazku)
  23.         });
  24.  
  25.         $(document).delegate('a.ajax', 'click', function(event) {
  26.             event.preventDefault();
  27.             $.get(this.href);
  28.         });
  29.         $(document).delegate('form.ajax', 'submit', function(event) {
  30.             event.preventDefault();
  31.             $.post(this.action, $(this).serialize());
  32.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement