Getting 0 As Status

Izaki

New Member
I have a simple HTML file, that gets data from the server and outputs it:\[code\]<html> <head> <script type="text/javascript"> var xmlhttp = new XMLHttpRequest(); function startRequest() { xmlhttp.onreadystatechange = handleStateChange; xmlhttp.open("GET", "http://new-host-2.home/test.html", true); xmlhttp.send(null); } function handleStateChange() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { alert("The server replied with: ", xmlhttp.responseText); } else { alert(xmlhttp.status); } } } </script> </head> <body> <form> <input type="button" value="http://stackoverflow.com/questions/10961594/Woooo" onclick="startRequest()"/> </form> </body></html>\[/code\]The file that is on the server, test.html looks like this:\[code\]<h1>Data received!</h1>\[/code\]I keep getting 0 as a status, despite the fact that in the console, it says everything is fine, and gives a 200 status. When I change \[code\]if (xmlhttp.status == 200)\[/code\] to \[code\]if (xmlhttp.status == 0)\[/code\], it just outputs \[code\]The server replied with:\[/code\]. Why is this? Am I messing something up?EDIT: It might just be my server, I'm gonna switch to a different one.The Headers might be helpful:\[code\]Response HeadersAccept-Ranges bytesConnection Keep-AliveContent-Length 13Content-Type text/htmlDate Sat, 09 Jun 2012 14:17:11 GMTEtag "267749b-d-4c20a6d0ef180"Keep-Alive timeout=15, max=100Last-Modified Sat, 09 Jun 2012 13:52:22 GMTServer Apache/2.2.19 (Unix) DAV/2Request HeadersAccept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encoding gzip, deflateAccept-Language en-us,en;q=0.5Connection keep-aliveHost new-host-2.homeOrigin nullUser-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0\[/code\]
 
Back
Top