I have hit a wall with this issue. I guess it is some kind of IE bug but I want to be sure.
So the question is. Why does IE10 XmlHttpRequest.status returns 0 instead of 401?
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
document.getElementById("rescode").innerHTML="Request completed with status: "+xmlhttp.status;
}
}
xmlhttp.open("GET","http://hosting.gregy.cz/cors/",true);
xmlhttp.send();
See plunker here: http://plnkr.co/edit/E2lCflPDHHaQi7t79IeM?p=preview
This code fires a CORS request which always returns 401. Firefox and chrome correctly return 401 in status attribute but IE10 returns 0. This issue breaks authentication handling methods I use for my project.
Thank you
Edit:
I have modified the plunker with onload and onerror event handlers (tip from monsur's comment), but the result is still the same.
I have also made sure IE10 has no compatibility mode selected. (tip from cernunnos's comment)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…