I am trying to call an ajax request again after the internet failure.
Can anyone help me with this? Here is my code.
var loadAgain = function(){
$.ajax({url: 'URL',
success: function(result){
alert('Success');
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
if (XMLHttpRequest.readyState == 0) {
alert('No internet connection');
setTimeout(loadAgain, 500);
}
else {
alert('Other Issue');
}
}
});
}
Edited: I have seen another option but I want to recall the ajax on internet disconnect.