jQuery: The Write Less, Do More JavaScript Library

Ajax/ajaxError

From jQuery JavaScript Library

Jump to: navigation, search

« Back to Ajax

ajaxError( callback )

Attach a function to be executed whenever an AJAX request fails. This is an Ajax Event.
The XMLHttpRequest and settings used for that request are passed as arguments to the callback. A third argument, an exception object, is passed if an exception occured while processing the request.
Arguments:
callbackFunction
The function to execute.
function (XMLHttpRequest, ajaxOptions, thrownError) {
  // thrownError only passed if an error was caught
  this; // dom element listening
}

Examples:
Show a message when an AJAX request fails.

 $("#msg").ajaxError(function(request, settings){
   $(this).append("<li>Error requesting page " + settings.url + "</li>");
 });

NameType