This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enhance the original "$.ajax" with a retry mechanism | |
$.ajax = (($oldAjax) => { | |
// on fail, retry by creating a new Ajax deferred | |
function check(a,b,c){ | |
var shouldRetry = b != 'success' && b != 'parsererror'; | |
if( shouldRetry && --this.retries > 0 ) | |
setTimeout(() => { $.ajax(this) }, this.retryInterval || 100); | |
} | |
return settings => $oldAjax(settings).always(check) |