MANSOUL
MANSOUL
  • 发布:2015-11-18 20:07
  • 更新:2015-11-20 13:20
  • 阅读:2354

刚使用web,XMLHttpRequest问题,无法跨域

分类:HTML5+

var xhr=new plus.net.XMLHttpRequest();
xhr.onreadystatechange=function(){
switch ( xhr.readyState ) {
case 4:
if ( xhr.status == 200 ) {
console.log("xhr请求成功:"+xhr.responseText);
} else {
console.log("xhr请求失败:"+xhr.responseText);
}
break;
default :
break;
}
};
xhr.open( 'POST', 'http://testapp.hooup.cn/sps/salesman/login.do' );
xhr.setRequestHeader('Content-Type','application/json');
var data = {'mobile':'6012','pwd':'6012'};
xhr.send(JSON.stringify(data));
返回的内容为:
xhr请求失败:<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.4.6 (Ubuntu)</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->

使用的时直接用的运行在真机 上调试

2015-11-18 20:07 负责人:无 分享
已邀请:
MANSOUL

MANSOUL (作者) - 新鲜感最重要

问题已解决,确实可以跨域。

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