Pseudo code:
$(document).ajaxError(function(e, xhr, options, error) { xhr.retry() })
Even better would be some kind of exponential back-off