잘못된 Ajax 작업의 경우 HTTP 헤더 코드를 403으로 설정하고 다음 응답을 보냅니다.
{"code":"403","status":"Forbidden","message":"You cannot do this"}
그러나 오류를 처리 할 때이 데이터에 액세스 할 수 없습니다. jqXHR에서 "메시지"데이터에 액세스 할 수 있습니까?
jqXHR.message와 같은 것?
도움을 주셔서 감사합니다 ...
편집하다 :
error: function (xhr) {
$(".alert").html(xhr.responseText);
},
다음을 반환합니다.
{"code":"403","status":"Forbidden","message":"You cannot do this"}
그러나 xhr.responseText.message는 아무것도 반환하지 않습니다 ...
편집 :이 코드는 작동합니다 :
error: function (xhr) {
var jsonResponse = JSON.parse(xhr.responseText);
$(".alert").html(jsonResponse.message);
},
당신은 jQuery '오류'콜백에 들어가야합니다 ... http://api.jquery.com/jQuery.ajax/
error: function(xhr, status, error) {
alert(xhr.responseText);
}
(btw .. ur 코드?)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다