您的位置:首页 > 产品设计 > UI/UE

mui aiax 与服务器后台数据交互

2017-08-20 12:04 351 查看
url:不能是localhost 或127.0.0.1;只能是服务器的ip地址

本地测试,手机要和本地服务在同一个局域网才可以。
并且,ip地址需要填写真实的子网地址,不可用localhost以及127.0.0.1。

例如

mui.ajax('http://ip地址/MobileInterface/InterfaceService.aspx', {
data: {
request_id: 'login',
user_id: 'admin',
password: '123456'
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: {
'Content-Type': 'application/json'
},
success: function(data) {
//服务器返回响应,根据响应结果,分析是否登录成功;
//...
console.log('success');
},//
error: function(xhr, type, errorThrown) {
//异常处理;
console.log('false');
console.log(type+":"+xhr+":"+errorThrown);
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: