我的ajax代码是:
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
alert(xhr.status);
if (xhr.status == 200) {
alert("200");
}
else if (xhr.status == 8001) {
alert("8001");
}
else if (xhr.status == 8000) {
alert("8000");
}
else if (xhr.status == 7000) {
alert("7000");
}
else {
alert("x");
}
}
};
xhr.open("POST","URL",true);
xhr.send(null);
我在 xhr.open 中处理的页面中的代码是:
if (request.getSession().getAttribute("SATI_UID") == null) {
response.sendError(8000);
} else {
response.sendError(8001);
}
它可以在 Firefox 和 chrome 中工作,但在 safari 中我总是得到状态 200。我使用 safari 5.1.7。我也使用response.setStatus
而不是,response.sendError
但它不起作用。有人知道为什么会这样吗?