.ajaxError()The .ajaxError() method in jQuery is used to register a handler to be callled when Ajax requests complete with an error.
.ajaxError() syntax.ajaxError(handler)
handler is a function to call once the Ajax requests is complete with an error.
.ajaxError() exampleShow a message when an Ajax request completes.
HTML
<button id="ajaxReq">Ajax Request</button> <div id="result"></div> <div id="msg"></div>
jQuery
$( "#ajaxReq" ).click(function() {
$( "#result" ).load( "/res/test/ajax/missing.html" );
});
$( document ).ajaxError(function(event, jqxhr, settings, thrownError ) {
// only handling the URL we request.
if ( settings.url == "/res/test/ajax/missing.html" ) {
$( "#msg" ).text( "Triggered ajaxError handler." );
}
});
