之所以不会被触发,
.ajaxStart()是因为直到ajax请求执行完
之后 (直到被调用时为止) ,
您的处理程序才被注册。在
.ajaxStop()被注册后为好,但 之前
的请求完成,所以当它回来就迷上了运行。
要解决此问题,请 在 首次
$.ajax()致电 之前
将其移动:
$("#loading").ajaxStart(function() { $(this).show();}).ajaxStop(function() { $(this).hide(); $("#st-tree-container").show();});更新:从jQuery 1.9开始,AJAX事件应仅附加到文档。 http://jquery.com/upgrade-
guide/1.9/#ajax-events-should-be-attached-to-
document
$(document).ajaxStart(function() { $("#loading").show();});$(document).ajaxStop(function() { $("#loading").hide(); $("#st-tree-container").show();});


