码迷,mamicode.com
首页 > Web开发 > 详细

doviceone- http组件进行webservice的POST请求

时间:2017-01-13 09:02:56      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:usb   单位   style   baseurl   http   color   anim   网络   print   

var http = mm("do_Http");
    http.method = "POST"; // GET | POST
    http.timeout = 10000; // 超时时间 : 单位 毫秒
    http.contentType = "application/x-www-form-urlencoded"; // Content-Type
    http.url = baseUrl;
    http.body = "name=" + encodeURI(textf1.text) + "&pwd="
    + textf2.text;
    deviceone.print(http.url)
    http.on("success", function(data) {
        deviceone.print(JSON.stringify(data));

        nf.toast("登录成功");
        do_DataCache.saveData("loginer", data);
        do_App.closePage();
        do_App.openPage({
            source : "source://view/index.ui",
            statusBarState : "transparent",
            animationType : "push_r2l"
        });
    });
    http.on("fail", function(data) {
        deviceone.print(JSON.stringify(data));
        if (data.status == 404) {
            nf.toast("用户名或密码错误");
        } else {
            nf.toast("网络问题");
        }
        logbtn.animate(animLogB);
        logbtn.text = "登录";
        logbtn.enabled = true;
        probar1.visible = false;
        textf1.enabled = true;
        textf2.enabled = true;
    });
    http.request();

baseUrl = "http://192.168.1.75/yz_ws/WebServiceHb.asmx/CheckUser";

doviceone- http组件进行webservice的POST请求

标签:usb   单位   style   baseurl   http   color   anim   网络   print   

原文地址:http://www.cnblogs.com/mafeng/p/6281401.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!