2013-03-06 5 views
2
내가 $.ajax()$.ajaxSetup()error() 아약스 이벤트를 사용하고

: error(xhr,status,error) 나는 이러한 주장이 무엇인지 알고하지 않습니다 문제가있다.세 가지 인수를

그러나 .ajaxError(function(event,xhr,options,exc))의 인수를 이해할 수 없습니다. 누구나이 논증을 기술 할 수 있습니까? 특별히 event 인수 나에게 JQuery와 포럼에 .ajaxError(function(event,xhr,options,exc))

감사

답변

2

내가 설명 내 질문의 네 각 인수를 사용하는 예를 제공하고 answer 유용 얻을 수 있습니다 :

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.

+1

당신은 자신의 대답을 받아 들일 수 있습니다. 참고로, 그것은 나에게 도움이되었다. –