Below I will share with you an example of the MUi framework ajax request WebService interface, which has a good reference value and I hope it will be helpful to everyone.
The example is as follows:
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); } }); }); });
Note: If there is a problem with the returned format It will prompt: abort
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Pull-up loading example written in native ajax (graphic tutorial)
ajax implementation of WeChat web page Authorized login method (graphic tutorial)
##Detailed explanation of using ajax to submit a form to the database (no refresh)
The above is the detailed content of MUi framework ajax request WebService interface instance_AJAX related. For more information, please follow other related articles on the PHP Chinese website!