如题
cocos create 1.8.1 js语言环境 使用XMLHttpRequest 获取不到网页?
找到问题是 xhr.status 这个只一直是0 这个是为什么?
使用官方帮助文档的例子代码http://docs.cocos.com/creator/manual/zh/scripting/network.html,
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
var response = xhr.responseText;
console.log(response);
}
};
xhr.open(“GET”, “http://127.0.0.1/a.html”, true);
xhr.send();
我的步骤是:
1、在VSCODE按调试 然后弹出GOOGLE浏览器。
2、在VSCODE的控制台看输出结果。
3、xhr.status 这个只一直是0 这个是为什么?