参照官网例子写的http post请求,需要获取返回的json数据,但是一直获取不到,请教一下什么问题
//注册按钮响应函数
Login.prototype.onButtonLogin = function (){
console.log ('按了登录按钮')
var xhr = new Laya.HttpRequest();
xhr.http.timeout = 10000;//设置超时时间;
xhr.once(Event.COMPLETE,this,completeHandler);
xhr.once(Event.ERROR,this,errorHandler);
xhr.once(Event.PROGRESS,this,processHandler);
var sendData = {account:"aaa",password:"bbb"}
xhr.send("http://xxx/login", JSON.stringify(sendData), "post", "json", [size=14]["content-type","application/json"][/size]);
function processHandler(data){
console.log (data)
}
function completeHandler(e){
console.log (xhr.data)
};
function errorHandler(data){
console.log ('error')
}
};