js ajax请求时显示加载图片,请求结束后移除加载图片

//$(document).ajaxSend每个请求发出时都会触发,需要做处理,防止添加多个图片
//当所有 AJAX 请求发送时,添加加载中图片,转圈的那个
$(document).ajaxSend(function(e,xhr,opt){
    if($("#theloadingiconimg").length==0){
        $('body').append("");
    }
});
//当所有 AJAX 请求完成时,移除加载中图片,转圈的那个
$(document).ajaxStop(function(){
    $("#theloadingiconimg").remove()
});

你可能感兴趣的:(javascript,ajax,开发语言)