MUi 框架ajax請求WebService接口

mui.init();  ajax

            mui.plusReady(function()  json

            {  服務器

                document.getElementById('login').addEventListener('tap',function()  app

                {  ide

                    var UserName=document.getElementById("account").value;    ui

                    var Userpassword= hex_md5(document .getElementById("password").value);            spa

                    mui.ajax('http://XXXXX/Login.asmx/MgLogin',  code

                    {                 md5

                            data:"{'loginname':'"+UserName+"','password':'"+Userpassword+"','identifies':'123456','code':''}",                        get

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

                            }  

                    });   

                });  

            });

相關文章
相關標籤/搜索