존재하지 않는 리소스 (웹 서버와 동일한 호스트)를로드하려고 할 때 어떤 결과가 발생하는지 테스트하려면 다음 코드를 설정하십시오.
대신 내 DIV 메시지sorry, could not find URL
을 보여 보는
var wrongURL = "http://foo/bar.json"; // non-existent resource
$.ajax({
url: wrongURL,
dataType: 'json',
success: function(jsonResponse, textStatus, jqXHR) {
$.('#divOfInterest').html("you should never see this");
},
error: function(jqXHR, textStatus, errorThrown) {
$.('#divOfInterest').html("sorry, could not find URL");
}
});
// remainder of code...
, 내가 콘솔 오류 얻을 다음 $.ajax()
블록 error
호출 내에서 이후
GET http://foo/bar.json 404 (Not Found) - bar.json
아무것도 (즉, // remainder of code
는)
내 브라우저 (Safari 5.1.5)가 404 오류에서 멈추고 기능을 일찍 끝내는 것처럼 보입니다.
오류를 정상적으로 처리하고 나머지 코드는 어떻게 처리합니까?
사파리에서도 작동합니다. 5.0.2 – ocanal