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

来源:互联网 发布:手机游戏盒子软件 编辑:程序博客网 时间:2024/06/08 08:43

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);
}
});

原创粉丝点击