美文网首页
ajax封装

ajax封装

作者: 苍耳兔兔 | 来源:发表于2017-03-28 17:20 被阅读0次
    function request(url,postData,doSuccess,doFail,doComplete){
        var host = getApp().conf.host;
        wx.request({
            url: host+url,
            data:postData,
            method: 'POST', 
            success: function(res){
                if(typeof doSuccess == "function"){
                    doSuccess(res);
                }
            },
            fail: function() {
                if(typeof doFail == "function"){
                    doFail();
                }
            },
            complete: function() {
                if(typeof doComplete == "function"){
                    doComplete();
                }
            }
         });
    }
    
    function ueajax(url,postData,doSuccess,doFail,doComplete){
        var   host = window.location.host;
        $.ajax({
            url: host+url,
            data:postData,
            method: 'POST', 
            success: function(res){
                if(typeof doSuccess == "function"){
                    doSuccess(res);
                }
            },
            fail: function() {
                if(typeof doFail == "function"){
                    doFail();
                }
            },
            complete: function() {
                if(typeof doComplete == "function"){
                    doComplete();
                }
            }
         });
    }
    
    
    

    相关文章

      网友评论

          本文标题:ajax封装

          本文链接:https://www.haomeiwen.com/subject/qzzjottx.html