For some reason, while using AJAX (with my dashcode developed application) the browser just stops uploading and returns status codes of 0
. Why does this happen?
We had similar problem - status code 0 on jquery ajax call - and it took us whole day to diagnose it. Since no one had mentioned this reason yet, I thought I'll share.
In our case the problem was HTTP server crash. Some bug in PHP was blowing Apache, so on client end it looked like this:
mirek@toccata:~$ telnet our.server.com 80
Trying 180.153.xxx.xxx...
Connected to our.server.com.
Escape character is '^]'.
GET /test.php HTTP/1.0
Host: our.server.com
Connection closed by foreign host.
mirek@toccata:~$
where test.php contained the crashing code. No data returned from the server (not even headers) => ajax call was aborted with status 0.
I found another case where jquery gives you status code 0 -- if for some reason XMLHttpRequest is not defined, you'll get this error.
Obviously this won't normally happen on the web, but a bug in a nightly firefox build caused this to crop up in an add-on I was writing. :)
Same problem here when using <button onclick="">submit</button>
. Then solved by using <input type="button" onclick="">
I had the same problem, and it was related to XSS (cross site scripting) block by the browser. I managed to make it work using a server.
Take a look at: http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/282972/why-am-i-getting-xmlhttprequest.status0
In my case, it was caused by running my django server under http://127.0.0.1:8000/
but sending the ajax call to http://localhost:8000/
. Even though you would expect them to map to the same address, they don't so make sure you're not sending your requests to localhost.
Another case:
It could be possible to get a status code of 0
if you have sent an AJAX call and a refresh of the browser was triggered before getting the AJAX response. The AJAX call will be cancelled and you will get this status.