Ajax

英 [?e??d??ks]? ?美 [?e?d??ks]??

n.全稱為“Asynchronous JavaScript and XML”(異步JavaScript和XML);是指一種創(chuàng)建交互式網(wǎng)頁應(yīng)用的網(wǎng)頁開發(fā)技術(shù)。;艾杰克斯銅錫鉛軸承合金,亞甲斯炸藥

errors

n.錯誤( error的名詞復(fù)數(shù) );過失,失誤

ajax ajaxError()方法 語法

作用:ajaxError() 方法在 AJAX 請求發(fā)生錯誤時執(zhí)行函數(shù)。它是一個 Ajax 事件。

語法:.ajaxError(function(event,xhr,options,exc))

參數(shù):

參數(shù)描述
function(event,xhr,options,exc)必需。規(guī)定當(dāng)請求失敗時運(yùn)行的函數(shù)。額外的參數(shù):event?- 包含 event 對象xhr?- 包含 XMLHttpRequest 對象options?- 包含 AJAX 請求中使用的選項(xiàng)exc?- 包含 JavaScript exception。

說明:XMLHttpRequest 對象和設(shè)置作為參數(shù)傳遞給回調(diào)函數(shù)。捕捉到的錯誤可作為最后一個參數(shù)傳遞:function (event, XMLHttpRequest, ajaxOptions, thrownError) {// thrownError 只有當(dāng)異常發(fā)生時才會被傳遞 this;}

ajax ajaxError()方法 示例

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("div").ajaxError(function(){
    alert("發(fā)生錯誤!");
  });
  $("button").click(function(){
    $("h2").text("文本已經(jīng)改變");
  });
});
</script>
</head>

<body>
<div id="txt"><h2>通過 AJAX 改變文本</h2></div>
<button>改變內(nèi)容</button>
</body>
</html>
運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例