Skip to content

Commit

Permalink
Override jQuery.ajax
Browse files Browse the repository at this point in the history
* Override jQuery.ajax
* Add jQuery.ajaxRetrySettings
* Add jQuery.ajaxRetrySetup
* Reflect changes to test
  • Loading branch information
execjosh committed Jul 7, 2010
1 parent e8cb7de commit 5ba5624
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/jquery.ajaxretry.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@
};

return xhr;
},
ajaxRetrySetup = function(opts){
DEF_OPTS = $.extend(true, DEF_OPTS, opts);
$.ajaxRetrySettings = DEF_OPTS;
return DEF_OPTS;
};

ajaxWithRetry.retrySetup = function(opts){
DEF_OPTS = $.extend(true, DEF_OPTS, opts || {});
return DEF_OPTS;
};

$['ajaxWithRetry'] = ajaxWithRetry;
$['ajaxRetrySettings'] = DEF_OPTS;
$['ajaxRetrySetup'] = ajaxRetrySetup,
$['ajax'] = ajaxWithRetry;
})(jQuery);

// vim: ts=4:sw=4:sts=4:noet:
Expand Down
4 changes: 2 additions & 2 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

// Set-up
$(document).ready(function(){
var retry_defaults = $.ajaxWithRetry.retrySetup({
var retry_defaults = $.ajaxRetrySetup({
attempts: 30,
cutoff: 7,
slot_time: 100,
Expand All @@ -83,7 +83,7 @@
tick: on_tick, // Tick callback
slot_time: $('#slot_time').val() // Slot time (duration between ticks)
};
$.ajaxWithRetry({
$.ajax({
url: 'this/file/does/not/exist',
retry: retry_opts,
error: on_error,
Expand Down
6 changes: 6 additions & 0 deletions test/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
for ($i = 0; $i < 10000; $i++) {
;
}
?>
{"name":"value}

0 comments on commit 5ba5624

Please sign in to comment.