var url = 'http://www.baidu.com';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function ()
{
cc.log("readyState:"+xhr.readyState+" status:"+xhr.status);
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400))
{
var response = xhr.responseText;
cc.log(response);
}
};
xhr.open("GET", url, true);
xhr.send();
无论网址是什么,始终是 readyState:4 status:0
这是为什么呢?