jQuery ajaxError () method
Examples
When AJAX request fails, triggering an alert box:
$(document).ajaxError(function(){
alert("An error occurred!");
});
alert("An error occurred!");
});
try it"
Definition and Usage
ajaxError () method specifies AJAX request functions to run on failure.
Note: Since jQuery version 1.8 onwards, this method is only attached to the document.
grammar
$(document).ajaxError(function(event,xhr,options,exc))
参数 | 描述 |
---|---|
function(event,xhr,options,exc) |
必需。规定当请求失败时运行的函数。 额外的参数:
|
More examples
Use xhr parameters and options
How to use the options parameter to get a more useful error message.