jQuery ajaxError() 메서드

❮ jQuery AJAX 메소드

예시

AJAX 요청이 실패하면 경고 상자를 트리거합니다.

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

정의 및 사용

ajaxError() 메서드는 AJAX 요청이 실패할 때 실행할 함수를 지정합니다.

참고: jQuery 버전 1.8부터 이 메서드는 문서에만 첨부되어야 합니다.


통사론

$(document).ajaxError(function(event,xhr,options,exc))

Parameter Description
function(event,xhr,options,exc) Required. Specifies the function to run if the request fails
Additional parameters:
  • event - contains the event object
  • xhr - contains the XMLHttpRequest object
  • options - contains the options used in the AJAX request
  • exc - contains the JavaScript exception, if one occurred

직접 해보십시오 - 예


사용 옵션 매개변수를 사용하여 더 유용한 오류 메시지를 얻는 방법.


❮ jQuery AJAX 메소드