Reputation: 9
I am trying to make a XMLHttpRequest Request to a content which is on local, runnin on local webserver from a HTML File and javascript residing locally.
it will hit the webserver request, and then even thou it sends the data back, in my javascript, at once I get readyState 4 and status as 0.
If i try putting the pages in the webserver foloder and access them as webpage slke http;//localhost/ filename then it works fine.
Upvotes: 0
Views: 3416
Reputation: 344585
This is to do with the fact that HTTP status codes are returned by web servers and, since you're accessing the local file system, a status code can't be returned -- hence Unknown (0)
. Some links:
responseText
. The most suitable workaround for the time being is JSON with Padding.
Upvotes: 3