Created
January 30, 2019 02:48
-
-
Save fazlurr/7b4a703bc80949f58b1903ae65a3b8a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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