This is the error function of $.ajax.
Why can’t I delay the call to $.ajax(this) ?
This works:
error: function (req, status, error) {
$.ajax(this);
return;
}
But this doesn’t
error: function (req, status, error) {
var retry = function () { $.ajax(this); };
setTimeout(retry, 100);
return;
}
Because the
setTimeoutcallback runs in the context of the global object.Therefore,
thisiswindow, not the AJAX settings.You need to store
thisin a variable.