jQuery API jQuery API 中英文对照版
ajaxError(callback)
ajaxError(callback)

绑定一个当一个AJAX请求失败时执行的函数。

返回值:jQuery

参数:

  • callback (Function): 执行的函数。

示例:

显示一个请求失败的信息。

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

ajaxError( callback )

Attach a function to be executed whenever an AJAX request fails.

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.

Return value: jQuery
Parameters:

  • callback (Function): The function to execute.

Example:

Show a message when an AJAX request fails.

 $("#msg").ajaxError(function(request, settings){
     $(this).append("<li>Error requesting page " + settings.url + "</li>");   
 });  
相关链接
asp之家 | jQuery官方网站 | jQuery中文网 | 电子书作者网站 | 电子书作者blog