-
Notifications
You must be signed in to change notification settings - Fork 6
/
jQuery.ajaxRetry.min.js
2 lines (2 loc) · 1.28 KB
/
jQuery.ajaxRetry.min.js
1
2
/*! jQuery.ajaxRetry v0.1.3 | (c) 2013 Daniel Herman | opensource.org/licenses/MIT | https://github.com/dcherman/jQuery.ajaxRetry */
!function(a){"use strict";function b(a){return a.state?"pending"!==a.state():a.isResolved()||a.isRejected()}var c="__RETRY__"+(new Date).getTime();a.ajaxPrefilter(function(d,e,f){if(!d[c]&&"undefined"!=typeof d.shouldRetry){e[c]=!0;var g,h,i=a.Deferred(),j=a.Deferred(),k={},l=0,m=function(b,c,e){var f,g=d.shouldRetry,h=typeof g;switch(h){case"number":f=g>c;break;case"boolean":f=g;break;case"function":f=g(b,c,e)}return"object"==typeof f&&"function"==typeof f.then?a.Deferred(function(a){f.then(a.resolve,function(){a.resolve(!1)})}).promise():a.when(f)};g=a.extend({},e,{success:a.noop,error:a.noop,complete:a.noop,statusCode:{}}),function n(b,c,d){(c?m(c,l++,b.type||"GET"):a.when(!0)).done(function(e){e===!0?(c?a.ajax(b):f).then(function(a,b,c){h=c.status,i.resolveWith(this,arguments),i.done(k[h]),j.resolveWith(this,[c,b])},function(a,c){var d=arguments,e=this;n(b,a,function(){h=a.status,i.rejectWith(e,d),i.fail(k[h]),j.resolveWith(e,[a,c])})}):d()})}(g),f.complete&&(f.complete=j.done,f.success=i.done,f.error=i.fail),a.extend(f,i.promise()),f.statusCode=function(a){var c;if(a)if(b(i))i.then(a[h],a[h]);else for(c in a)k[c]=[k[c],a[c]];return this}}})}(jQuery);