异常描述
本地环境下,直接打开html文件,用AJAX 方法jQuery load()
加载txt文件时,报错如下:
Access to XMLHttpRequest at ‘http://127.0.0.1:81/testSHT/js.txt’ from origin ‘null’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
GET http://127.0.0.1:81/testSHT/js.txt net::ERR_FAILED 404 (Not Found)
其中,测试的相关代码已经上传资源绑定,代码相对简单,没有错误,只有一个html文件和txt文件,也可以直接查看本博文测试源码的小节进行获取。jquery库引用的是百度CDN(内容分发网络)的,如下: