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();
}
});