MUi框架ajax请求WebService接口实例

栏目: 编程语言 · JavaScript · jQuery · 发布时间: 7年前

内容简介:下面小编就为大家分享一篇MUi框架ajax请求WebService接口实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

实例如下所示:

mui.init(); 
      mui.plusReady(function() 
      { 
        document.getElementById('login').addEventListener('tap',function() 
        { 
          var UserName=document.getElementById("account").value;  
          var Userpassword= hex_md5(document .getElementById("password").value);      
          mui.ajax('http://XXXXX/Login.asmx/MgLogin', 
          {         
              data:"{'loginname':'"+UserName+"','password':'"+Userpassword+"','identifies':'123456','code':''}",            
              type:'POST',//HTTP请求类型 
              dataType:'json',//服务器返回json格式数据 
              timeout:10000,//超时时间设置为10秒; 
              headers:{'Content-Type':'application/json'},          
              success:function(data) 
              { 
                //服务器返回响应,根据响应结果,分析是否登录成功; 
                var jsons=data.d; 
                var str=JSON.parse(jsons); 
                if(str["StatusCode"]=="200") 
                { 
                  mui.alert("登陆成功"); 
                }else 
                { 
                  mui.alert("登陆失败");  
                } 
              }, 
              error:function(xhr,type,errorThrown) 
              { 
                //异常处理;                
                mui.alert(type); 
                console.log(type); 
              } 
          });  
        }); 
      }); 

注意:如果返回的格式有问题会提示:abort


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Creative Curve

The Creative Curve

Allen Gannett / Knopf Doubleday Publishing Group / 2018-6-12

Big data entrepreneur Allen Gannett overturns the mythology around creative genius, and reveals the science and secrets behind achieving breakout commercial success in any field. We have been s......一起来看看 《The Creative Curve》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具