我的Ajax代码是:AJAX就绪状态reachs 4,但状态始终是200
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和铬和ie,但在safari我总是得到状态200. 我使用safari 5.1.7。我也使用response.setStatus
而不是response.sendError
,但它不起作用。有人知道为什么会发生这种情况吗?