Easy Tutorial
❮ Html Removeprop Sel Class ❯

jQuery ajaxError() Method

jQuery AJAX Methods

Example

Trigger an alert box when an AJAX request fails:

$(document).ajaxError(function(){
    alert("An error occurred!");
});

Definition and Usage

The ajaxError() method specifies a function to run when an AJAX request fails.

Note: As of jQuery version 1.8, this method only attaches to the document.


Syntax

Parameter Description
function(event,xhr,options,exc) Required. Specifies the function to run when the request fails. <br> Additional parameters: <br> event - Contains the event object <br> xhr - Contains the XMLHttpRequest object <br> options - Contains the options used in the AJAX request <br> exc - Contains the JavaScript exception

More Examples

Using xhr and options parameters


jQuery AJAX Methods

❮ Html Removeprop Sel Class ❯