我正在使用 ajax 调用来检索一些 HTML 数据。在某些情况下,我可能会收到 HTTP 错误 403(因为在 IE上使用 ajax 调用时遇到一些 IE 错误遇到 403 错误,带有正斜杠的哈希片段在 IE 中使用 AJAX 请求引发 403 错误)。
出于错误处理的目的,我想捕捉发生了什么错误并相应地显示一些错误消息。
我怎么做?
也许像
$.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
}
});