2

私はerror()Ajax イベントを使用しており$.ajax()$.ajaxSetup()それには 3 つの引数がerror(xhr,status,error)あります。これらの引数が何であるかはわかっており、問題はありません。

しかし、 の引数を理解できません.ajaxError(function(event,xhr,options,exc))4 つのそれぞれについて、これらの議論を説明できる人はいますか? 特にevent引数。の4つの引数のそれぞれを使用する例を教えてください.ajaxError(function(event,xhr,options,exc))

よろしく

4

1 に答える 1

2

JQuery Forums で自分の質問について話し合ったところ、役立つ回答が得られました

event is an ajaxError event object and doesn't contain any particularly useful information. xhr is the jQuery wrapper around the XMLHttpRequest object that made the request - useful attributes are status and statusText. options is the full set of options sent to the ajax request - useful attributes are url, isLocal, and type. exc is the exception thrown - useful attributes are filename and message, and possibly lineNumber and columnNumber.

$('#results').ajaxError(function(event, xhr, options, exc) {
  $(this).text('Couldn\'t load ' + options.url + ' because (' +
        xhr.status + ' - ' + xhr.statusText + ') ' + exc.message);
});

The Event Object (page 173)さらに、本のセクションを学びましJavaScript & jQuery: The Missing Manual, 2nd Editionた。セクションの金額は次のとおりです。

イベント オブジェクト Whenever a web browser fires an event, it records information about the event and stores it in an event object. The event object contains information that was collected when the event occurred, like the vertical and horizontal coordinates of the mouse, the element on which the event occurred, or whether the Shift key was pressed when the event was triggered.

そして今、それが理解できなかったことを知っています。たったひとつ:

$.ajaxError event(parameter) attributes. 誰かが私がデバッグを行って非常に有用な情報を見て見つけFirebugたいくつかのインスタンスを明示的に教えてもらえますか?event Object$.ajaxError parameters.

于 2013-03-07T11:34:14.043 に答える