jquery-ajax-retry
jquery-ajax-retry copied to clipboard
Possible to reuse callbacks from previous XHR request?
I have a configuration where I add a retry
to every request globally via ajaxPrefilter
, for cases where I get timeouts from Heroku.
It goes along the lines of:
jqXHR
.retry({
times: 2,
statusCodes: [503]
})
.fail(function(xhr) {
alert(...);
});
This means any done
callbacks are set previously to using retry
.
Thing is, when a 503 error is returned, followed by a success, the success callbacks aren't called.
Hmm, I see what you mean. I need to think about how to handle this. For your specific example, I think that you can work around by using .then(successHandler, failureHandler)
instead of .fail
.
At this point, in my specific case, I don't have direct access to the handlers, since I do this globally, but set the handlers initially at a different point.
There might be a way to work around this, but I couldn't find a way that doesn't require changing my original AJAX call.