1.XMLHttpRequest status = 0 问题

XMLHttpRequest的说明:http://www.w3.org/TR/XMLHttpRequest/ 。

The status attribute must return the result of running these steps:

status的值一定会返回运行这些步骤的结果。

1、If the state is UNSENT or OPENED, return 0.(如果状态是UNSENT或者OPENED,返回0)
2、If the error flag is set, return 0.(如果错误标签被设置,返回0)
3、Return the HTTP status code.(返回HTTP状态码)

情况一:

xmlhttp自己在模拟,因为根本就没通过服务器。本地直接打开而已。OPENED了,所以status为0。

情况二:

浏览器跨域的返回头没有允许,所以浏览器阻止Access-Control-Allow-Origin这个属性。

解决方案:

在自己的服务器,访问自己域名内的url。

 

2.XMLHttpRequest.status == 200 && XMLHttpRequest.readyState ==4  但 返回值为 null

 

相关文章:

  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2021-06-20
  • 2021-10-16
  • 2022-12-23
  • 2022-02-09
猜你喜欢
  • 2021-08-28
  • 2021-10-14
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2021-08-21
  • 2021-09-27
相关资源
相似解决方案