var name=(this.parent.getChildByName("nameeditbox")).getComponent(cc.EditBox);
var strname=name.string;
var pwd=(this.parent.getChildByName("passwordseditbox")).getComponent(cc.EditBox);
var strpwd=pwd.string;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
var response = xhr.responseText;
if(response=='-1'){
alert("用户名不存在!");
}
else if(response=='-2'){
alert("用户名或密码不正确!");
}
else{
cc.sys.localStorage.setItem('daxiong_username',strname);
cc.sys.localStorage.setItem('daxiong_password',strpwd);
cc.director.loadScene("HomePage");
}
}
};
xhr.open("GET", config.URL+'/user.ashx?username='+strname+'&password='+strpwd+'&type=1002', true);
xhr.send();
代码如上。在creator中浏览器浏览,一切正常,但是打包成apk,安装到手机上,http请求就无法发送出去,这是什么原因呢?难道原生的不支持http请求?
