weixin_33727510 2013-03-27 22:21 采纳率: 0%
浏览 40

Ajax动画JQuery 1.9.2

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条回答 默认 最新

  • bug^君 2013-03-27 22:25
    关注

    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"); });
    
    评论

报告相同问题?