My company's website uses jQuery ajax to submit forms. A high percentage (5% - 10%) are failing, causing the ajax's error handler to run in the client's browser. The error handler looks like this:
$.ajaxSetup({
type: 'post',
error: function (request, textStatus, errorThrown) {
if (developmentMode) return;
$.post('/error/LogAjaxError', { err: 'headers:' + (request.getAllResponseHeaders ? request.getAllResponseHeaders() : '') });
setTimeout(function () {
location.href = (appRoot + 'error/500');
}, 500);
}
});
error/LogAjaxError
successfully logs these errors, which is how we know the percentage. Now it's not a server error, because
- we are using Elmah, (which normally works great,) but is not catching any error on these ajax calls
- we can see that the ajax server code ran until the end without error, as it adds a db record in the last line
It is also unlikely to be a network issue, since the client successfully sends an ajax call to error/LogAjaxError
a few ms later.
Does anyone have an idea what the issue could be, since it doesn't seem to be a server or a network error?
Mostly the clients are using mobile devices. Are there any statistics as to what percentage of ajax requests from mobile devices are expected to fail?