Skip to content

Instantly share code, notes, and snippets.

@fazlurr
Created January 30, 2019 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fazlurr/7b4a703bc80949f58b1903ae65a3b8a8 to your computer and use it in GitHub Desktop.
Save fazlurr/7b4a703bc80949f58b1903ae65a3b8a8 to your computer and use it in GitHub Desktop.
$.ajax({
url : 'someurl',
type : 'POST',
data : ....,
tryCount : 0,
retryLimit : 3,
success : function(json) {
//do something
},
error : function(xhr, textStatus, errorThrown ) {
if (textStatus == 'timeout') {
this.tryCount++;
if (this.tryCount <= this.retryLimit) {
//try again
$.ajax(this);
return;
}
return;
}
if (xhr.status == 500) {
//handle error
} else {
//handle error
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment