jQuery ajax - ajaxError() method
Example
Trigger a prompt box when the AJAX request fails:
$("div").ajaxError(function(){ alert("An error occurred!"); });
Definition and Usage
The ajaxError() method executes a function when an AJAX request occurs an error. It is an Ajax event.
Syntax
.ajaxError(function(event,xhr,options,exc))
Parameters | Description |
---|---|
function(event,xhr,options,exc) |
Required. Specifies the function to be executed when the request fails. Additional Parameters:
|
Detailed Description
The XMLHttpRequest object and settings are passed to the callback function as parameters. The caught error can be passed as the last parameter:
function (event, XMLHttpRequest, ajaxOptions, thrownError) { // thrownError will be passed to this only when an exception occurs; }