手机浏览器ajax error XMLHttpRequest.status=0

maxldwy 2016-06-07 02:06:25
我做了个h5页面 用zepto ajax跨域请求 在浏览器上http://172.16.71.230:8020/jxs/html/home.html访问http://www.xuedao99.com/api/index.php/user/login接口 可以得到数据
但是在浏览器上用http://172.16.71.230:8020/jxs/html/home.html这个ip地址打开html并且访问接口就会提示error 并且 XMLHttpRequest.status=0
用的是zepto.js
$.ajax({
type: "post",
url: "http://www.xuedao99.com/api/index.php/user/login",
async: true,
headers:{"Content-Type":"application/x-www-form-urlencoded","Origin": "*"},
dataType: "json",
data : {
username: document.getElementById("account").value,
password: document.getElementById("password").value
},
success: function(data) {
alert(123);
if (data.status == 1) {
mui.openWindow({
id: 'html/home.html',
url: 'html/home.html',
extras: {
userId:"11"
},
});
} else {
document.getElementById("mask").style.display = "none";
mui.toast("用户名或密码错误");
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.status);
}
});
...全文
377 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

52,785

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧