jQuery\'s AJAX error function has the following parameters:
error(XMLHttpRequest, textStatus, errorThrown)
What\'s the best cross-browser w
One straightforward usage example with jQuery:
var url = '/';
$.get(url).then(
function(response) {
$("#result").html(response);
},
function(jqXHR) {
$("#result").html('Error occurred: '+ jqXHR.statusText + ' ' + jqXHR.status);
}
);
This should return the HTML of current website front page.
Then try entering a nonsense URL that doesn't exist and see the error thrown. You should get "404 Not Found" from web server. Test it: JSFiddle here