|
用X5开发webapp测试阶段用ajax跨域请求另外一个服务端,具体情况如下:
电脑A:
用X5的studio启动内置tomcat,模拟运行前端代码,代码如下:
$.ajax({
"type" : "json",
"async" : false,
"data":
{
"userCde":username,
"password":userpass
},
"dataType" : "json",
"url" : "http://172.16.20.108:38080/bms/AppLoginController.do",
"success" : function(data)
{
alert(123);
if(data.status == '登录成功')
{
this.comp('output1').set({value:data.status});
if(this.comp('toggle4').val() == true)
{
localStorage.setItem('username', username);
localStorage.setItem('userpass', userpass);
}
window.location.href="main.w";
}else if(data.status == '用户名或密码错误')
{
this.comp('output1').set({value:data.status});
}else if(data.status == '用户已停用')
{
this.comp('output1').set({value:data.status});
}else if(data.status == '查询数据异常')
{
this.comp('output1').set({value:data.status});
}
},
电脑B:为服务端启动另外一个tomcat运行服务端代码 IP为172.16.20.108
电脑A向电脑B发送ajax请求失败 如何解决
|
-
ajax
|