我有ajax全局事件来显示文档上每个ajax的叠加层,它看起来像是:
$(document).ajaxSend(function (e, jqXHR) {
//show the loading div here
$('#DivProgressBar').show(); //if ajax is Post only
});
$(document).ajaxComplete(function (e, jqXHR) {
//remove the div here
$('#DivProgressBar').hide(); //if ajax is Post only
});
现在我希望这个叠加层仅适用于发布请求,而不适用于获取请求。 我可以修改我当前的jquery代码来实现这个吗?
感谢。
答案 0 :(得分:1)
您只能将$(document).ajaxSetup({type: 'POST'});
用于发布请求。
答案 1 :(得分:0)
jQuery(element).ajaxComplete(function(event, request, settings) {
alert(settings.type);
});