ajax封装

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封装)