0
我正在使用多个ajax调用。但使用AjaxSetUp
知道是否允许呼叫,如果不是,则尝试在beforeSend
方法中放弃此操作。如何在发送ajaxsetup的方法之前中止父ajax调用
这里是Ajax调用
$.ajax({
type : "POST",
url : "/apps/doAction",
xhrFields : "checkIfAllowed",
success : function(response,xhr) {
if(response){
return false;
}
},
error : function(xhr,ajaxOptions,thrownError) {
}
});
这里是AjaxSetUp
$.ajaxSetup({
beforeSend: function(event, xhr, settings) {
event.xhrToAbort=xhr;
if(xhr.xhrFields == "checkIfAllowed"){
$.ajax({
type : "POST",
url : contextpath+ "/apps/auth/isAllowed",
success : function(response,xhr) {
if(response){
// ABORT PARENT CALL ("URL: /apps/doAction") unable to abort parent call..
}
},
error : function(xhr,ajaxOptions,thrownError) {
}
});
}
},
complete: function(event, xhr, settings) {
$('.trans-overlay').hide();
}
});