[英]XMLHttpRequest request is resultin in ReadyState 4 and status is 200
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. 我正在尝试向本地内容,从本地HTML服务器上运行的HTML文件和JavaScript发出XMLHttpRequest请求。
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. 它将到达网络服务器请求,然后即使您将其发送回数据,也立即在我的JavaScript中,我得到readyState 4,状态为0。
If i try putting the pages in the webserver foloder and access them as webpage slke http;//localhost/ filename then it works fine. 如果我尝试将页面放在网络服务器文件中,并以slke http; /// localhost / filename的形式访问它们,则可以正常工作。
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)
. 这与以下事实有关:HTTP状态代码由Web服务器返回,并且由于您正在访问本地文件系统,因此无法返回状态代码-因此为Unknown (0)
。 Some links: 一些链接:
responseText
.
如果您尝试访问其他域,端口或协议上的文件,则请求将返回状态代码0,而responseText
则返回零。
The most suitable workaround for the time being is JSON with Padding .
目前最合适的解决方法是JSON with Padding 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.