【发布时间】:2012-02-15 18:05:09
【问题描述】:
我正在使用 ajax 调用来检索一些 HTML 数据。在某些情况下,我可能会收到 HTTP 错误 403(由于一些 IE 错误Encountering 403 error while using ajax call on IE、Hash fragments with forward-slash throwing 403 errors with AJAX requests in IE)。
出于错误处理的目的,我想捕捉发生了什么错误并相应地显示一些错误消息。
我该怎么做?
可能是这样的
$.ajax({
type : 'POST',
data : data,
cache : false,
url : url,
dataType : 'html'
success : function(){
//if HTTP response is ok, diplay data
//else if HTTP response gets 403 error, display some other message
}
});
【问题讨论】:
标签: ajax internet-explorer error-handling http-status-code-403 http-error