How can I bypass ajax success callbacks and run global success handler based on the response I get from the server?
$(document).ajaxSuccess(function (event, xhr, settings) {
if(xhr.responseText=="ignoreCustomSuccessHandler");
console.log("from global");
});
$.ajax({
success: function(data){
console.log("from success");
}
})
So if I get ignoreCustomSuccessHandler from the server, I want only the global success handler to run and ignore the one defined in success. That is, my log should be from global only.
Otherwise, my success callback should run, giving me the output from success.
I can check the condition inside success and get the desired result, but I am trying to write minimal code that can be applied to all ajax requests in my project.