更新时间:2023-12-05 16:10:40
我想你打算这样做(第二个使用 ajaxStop()
):
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"); });
查看它在jsFiddle的修改版本上的工作原理: http://jsfiddle.net/jfriend00/gk3RL/
See it working here on a modified version of your jsFiddle: http://jsfiddle.net/jfriend00/gk3RL/
此外,使用 document.body
代替"body"
:
$(document).ajaxStart(function(){ $(document.body).addClass("loading"); });
$(document).ajaxStop(function(){ $(document.body).removeClass("loading"); });