Javascript XMLHttpRequest “NetworkError”

*爱你&永不变心* 提交于 2019-12-05 04:03:00

I've run into the same problem. It seems to only happen on redirect responses. If you set your async flag to false and use a callback function then the error goes away. For example:

xmlhttp.open("GET","http://google.com", false);

Then you'll need a function like this to listen for the response:

xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    // do stuff here
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!