jquery ajax 中各个事件执行顺序如下:
1.ajaxStart(全局事件)
2.beforeSend
3.ajaxSend(全局事件)
4.success
5.ajaxSuccess(全局事件)
6.error
7.ajaxError (全局事件)
8.complete
9.ajaxComplete(全局事件)
10.ajaxStop(全局事件)
使用方法:
① 全局使用
$(document).ajaxStart(function(){
$("#wait").css("display","block");
});
$(document).ajaxComplete(function(){
$("#wait").css("display","none");
});
②局部使用
$("#ACCOUNT_TYPE").bind('click', function() { $.ajax({ type:"post", url:"${ctx}/Rule/Combination/getdict", data:{type:msg}, dataType:"json", success:function(json) { //... } , beforeSend:function(mes) { alert("beforeSend"); }, complete:function() { alert("complete"); } }); });