Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hey guys I don't know why i am getting XMLHttpRequest status 0 instead of 200 on localhost.

xhr=new XMLHttpRequest();

var urlDetail="abc.html";
xhr.open("GET",urlDetail,true);

xhr.onreadystatechange=function()
 {
   if(xhr.readyState==4)
    {
      if(xhr.status==200)
        {
           .....
        }
    }
 }
xhr.send(null);
Posted
Updated 14-Oct-14 0:55am
v2
Comments
Sergey Alexandrovich Kryukov 14-Oct-14 3:03am    
This code fragment does not give us any idea. You are only showing ready state and status; it doesn't tell anything about how you got this status.
—SA
KaushalJB 14-Oct-14 3:08am    
Which browser are you checking with ? This is browser dependent.. check here https://www.google.co.in/search?q=xhr&oq=xhr&aqs=chrome..69i57.424j0j4&sourceid=chrome&espv=2&es_sm=93&ie=UTF-8#q=xhr+status+always+0

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900