I've created a convenience method that adds a default error handler for my ajax calls:
function myAjaxFunction(url, data) {
return $.ajax({
url: url,
data: data
}).fail(myErrorHandler);
}
So far, this works great, because now I don't have to specify the error handler function in 50 different places.
But sometimes I need to override the default error handler with a custom one. When I do this, however, it calls both error handlers:
myAjaxFunction("myurl", "mydata").fail(myCustomErrorHandler).then(doSomething);
How do I get it to override or remove the previous error handler from the chain?