$.ajax({ url: 'http://', type: 'POST', data: {}, tryCount: 0, retryLimit: 3, success: function (response) { //do something }, error: function (xhr, textStatus, errorThrown) { this.tryCount++; if (this.tryCount <= this.retryLimit) { //try again $.ajax(this); return; } if (xhr.status == 500) { //handle error } else { //handle error } } }); |
Friday, March 30, 2018
What's the best way to retry an AJAX request on failure using jQuery | The best way to retry an AJAX request on failure using jQuery | jQuery AJAX retry
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment