I have an error callback defined in ajax setup, that will be executed in each ajax instance:
$.ajaxSetup({
cache: false,
error: function (data, textStatus, pStatusDescription) {
if (pStatusDescription === "Unauthorized")
{
// show dialog
alert("Your Login has expired. Please re-login.");
return;
}
}
});
Also I have a simple ajax request which has an own definition for the error handling. This definition overwrites the definition in $.ajaxSetup:
$.ajax({
url: "http://hostname",
success: function(xhr) { ... },
error: function(data, textStatus, pStatusDescription) {
if(pStatusDescription === "ObjectNotFound")
{
// remove Object
return;
}
// call 'error' callback in $.ajaxSetup now.
}
});
How can I bubble an error from an $.ajax instance to the $.ajaxSetup?
I think issue is: you are using ajaxSetup wrong way. Check the note in ajaxSetup docs:
So if you ajaxError instead of ajaxSetup, you can catch error inside ajaxError handler for global handler, and add additional handler for particular request inside 'error' parameter of $.ajax