0

How would i upgrade the solution provided in this question How can I create a "Please Wait, Loading..." animation using jQuery?

to work with JQuery 1.9.2?

I can't seem to get it to work. I've tried the following http://jsfiddle.net/VpDUG/2485/

$(document).ajaxStart(function(){   $("body").addClass("loading"); });
$(document).ajaxStart(function(){   $("body").removeClass("loading"); });

but that hasn't worked?

2 Answers 2

3

I think you meant to do this (using ajaxStop() for the second one):

$(document).ajaxStart(function(){   $("body").addClass("loading"); });
$(document).ajaxStop(function(){   $("body").removeClass("loading"); });

See it working here on a modified version of your jsFiddle: http://jsfiddle.net/jfriend00/gk3RL/


Also, a little more efficient to use document.body instead of "body":

$(document).ajaxStart(function(){   $(document.body).addClass("loading"); });
$(document).ajaxStop(function(){   $(document.body).removeClass("loading"); });
0
0

The second event should be ajaxComplete

$(document).ajaxComplete(function(){   $("body").removeClass("loading"); });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.