黑化肥发黑
黑化肥发黑
  • 发布:2016-03-28 15:16
  • 更新:2016-03-28 15:16
  • 阅读:1281

new plus.net.XMLHttpRequest() post请求 servlet 不能获取传递的数据

分类:HTML5+

var url="http://localhost:8288/zxmsp/mobile/mblogin";
var xhr=null;
var data={userName:'admin',password:'abc'};
function testXHR(){
if ( xhr ) {
console.log( "xhr请求已创建" );
return;
}
console.log( "创建请求:" );
xhr = new plus.net.XMLHttpRequest();
xhr.responseType
xhr.onreadystatechange = function () {
switch ( xhr.readyState ) {
case 0:
console.log( "xhr请求已初始化" );
break;
case 1:
console.log( "xhr请求已打开" );
break;
case 2:
console.log( "xhr请求已发送" );
break;
case 3:
console.log( "xhr请求已响应");
break;
case 4:
console.log( "xhr"+xhr.status);
if ( xhr.status == 200 ) {
console.log( "xhr请求成功:"+xhr.responseText );
} else {
console.log( "xhr请求失败:"+xhr.status );
}
break;
default :
break;
}
}
xhr.open( "POST", url );
xhr.setRequestHeader('Content-Type','application/json');
xhr.send(JSON.stringify(data));
}

2016-03-28 15:16 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复