欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery ajax - ajaxError() 方法

實(shí)例

當(dāng) AJAX 請(qǐng)求失敗時(shí),觸發(fā)提示框:

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

親自試一試

定義和用法

ajaxError() 方法在 AJAX 請(qǐng)求發(fā)生錯(cuò)誤時(shí)執(zhí)行函數(shù)。它是一個(gè) Ajax 事件。

語(yǔ)法

.ajaxError(function(event,xhr,options,exc))
參數(shù) 描述
function(event,xhr,options,exc)

必需。規(guī)定當(dāng)請(qǐng)求失敗時(shí)運(yùn)行的函數(shù)。

額外的參數(shù):

  • event - 包含 event 對(duì)象
  • xhr - 包含 XMLHttpRequest 對(duì)象
  • options - 包含 AJAX 請(qǐng)求中使用的選項(xiàng)
  • exc - 包含 JavaScript exception

詳細(xì)說(shuō)明

XMLHttpRequest 對(duì)象和設(shè)置作為參數(shù)傳遞給回調(diào)函數(shù)。捕捉到的錯(cuò)誤可作為最后一個(gè)參數(shù)傳遞:

function (event, XMLHttpRequest, ajaxOptions, thrownError) {
 // thrownError 只有當(dāng)異常發(fā)生時(shí)才會(huì)被傳遞 this;
 }

親自試一試 - 實(shí)例

使用 xhroptions 參數(shù)
如何使用 options 參數(shù)來(lái)獲得更有用的錯(cuò)誤消息。