jquery-ajax-retry icon indicating copy to clipboard operation
jquery-ajax-retry copied to clipboard

Possible to reuse callbacks from previous XHR request?

Open GeReV opened this issue 11 years ago • 2 comments

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.

GeReV avatar Sep 24 '13 15:09 GeReV

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.

johnkpaul avatar Sep 28 '13 16:09 johnkpaul

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.

GeReV avatar Sep 28 '13 16:09 GeReV