I want to have a global error handling method for ajax calls, this is what I have now:
$.ajaxSetup({
error: function (XMLHttpRequest, textStatus, errorThro
Building upon Alastair Pitts'a answer, you can also do this to have more informative messages:
$(document).ajaxError(function (e, jqXHR, ajaxSettings, thrownError)
{
{
if (jqXHR.status === 0)
{
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404)
{
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500)
{
alert('Internal Server Error [500].');
} else if (exception === 'parsererror')
{
alert('Requested JSON parse failed.');
} else if (exception === 'timeout')
{
alert('Time out error.');
} else if (exception === 'abort')
{
alert('Ajax request aborted.');
} else
{
alert('Uncaught Error.\n' + jqXHR.responseText);
}
}
});