如果在ajax中重定向,浏览器会返回正常的代码302,但是当我弹出一个显示状态代码时,它会显示0 ...我不明白为什么..
if (xhr_cpt != null) {
if (xhr_cpt.readyState == 4) {
clearTimeout(compteursTimeout);
compteursTimeout = null;
var status_code = xhr_cpt.status;
var status_text = xhr_cpt.statusText;
window.alert("Status Code : " + status_code + " \n Status Text : " + status_text);
if ((xhr_cpt.status >= 200 && xhr_cpt.status < 300)
|| (xhr_cpt.status == 0 && xhr_cpt.responseText != null && xhr_cpt.responseText.length > 0)) {
var resp_cpt;
try {
resp_cpt = JSON.parse(xhr_cpt.responseText);
} catch (e) {
resp_cpt = null;
}
treatCptResponse(resp_cpt);
}
else if (xhr_cpt.status == 0 || xhr_cpt.status >= 12000) {
// Pas de reponse, on incremente pas le cpt expiration
updateCompteursError(false);
}
else {
// Reponse invalide, on incremente le cpt expiration
updateCompteursError(true);
}
xhr_cpt.onreadystatechange = null;
xhr_cpt = null;
}
}