!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(b,c){var d=c.times,e=b.timeout;return function(f){function g(){a.ajax(h).retry({times:d-1,timeout:c.timeout,statusCodes:c.statusCodes}).pipe(i.resolve,i.reject)}var h=this,i=new a.Deferred,j=b.getResponseHeader("Retry-After");return d>1&&(!b.statusCodes||a.inArray(f.status,b.statusCodes)>-1)?(j&&(e=isNaN(j)?new Date(j).getTime()-a.now():1e3*parseInt(j,10),(isNaN(e)||0>e)&&(e=b.timeout)),void 0!==e?setTimeout(g,e):g()):i.rejectWith(this,arguments),i}}a.ajaxPrefilter(function(a,c,d){d.retry=function(a){return a.timeout&&(this.timeout=a.timeout),a.statusCodes&&(this.statusCodes=a.statusCodes),this.pipe(null,b(this,a))}})});
|