retryAjax – retry jQuery ajax requests

I wanted to write a little wrapper for jQuery’s Ajax function that would retry a request in the event of a transient failure. This could be quite a common scenario for a mobile optimized website where a users mobile device moves out of signal area briefly. I also wanted to add the ability to increase the time between request attempts with a backoff function so as not to waste requests.

I played around a bit with proxying jQuery’s core Ajax function in the sameway jquery-mockajax  does. I also discovered some other interesting options using jQuery prefilters which I wasnt aware of existed but will certainly be taking a deeper look into.

Anyway I settled on adding another method called ajaxWithRetries.

It’s my first stab at this on a lazy sunday arvo so its likely to be quite buggy (current retry count is not specific to an individual function for example) & I havent tested it on various browsers so use at your own risk 🙂

Its up on github at