實例如下所示:
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
以上這篇MUi框架ajax請求WebService接口實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com