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);
}
});
本地测试,手机要和本地服务在同一个局域网才可以。
并且,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);
}
});
相关文章推荐
- Ionic从零单排(三)——Ionic程序(前台)与服务器(后台)进行数据交互
- Android之使用HttpPost提交数据到服务器(Android手机客户端和后台服务器交互)
- Android与web服务器数据交互编程---3网络爬虫项目实现虚拟浏览器的jsp后台运行
- 【图解】前后台数据交互,方便纯前端程序员了解后台服务器处理
- Android客户端与后台服务器的数据交互
- Windows下使用TCP协议变长交互客户端和服务器的数据传输
- 利用AjaxPro2实现前后台数据交互
- 前后台数据交互
- 用Ajax以GET或POST的方式来和服务器进行数据交互
- Flash与后台数据交互方法总结
- ssh前后台交互, list传输到前后展示,table传输到台数据!!!。ssh对象传输
- Silverlight融合ajax实现前后台数据交互
- TP5(thinkPHP5)框架基于ajax与后台数据交互操作简单示例
- JSP前后台数据交互
- ASP.NET—007:GridView数据的保存($.ajax实现前后台交互)
- 解答”打包成功后的apk不能和后台服务进行数据交互“的问题
- .net网站与Winform窗体的数据交互(JS调用Winform后台方法实现)
- 前台与服务器数据交互乱码问题终极解决
- JQuery以及highchart与后台数据交互
- web前后台数据交互的几种方式