小程序全局ajax


util = {
request:function(appUrl,appData,called,type){
wx.showLoading({
title: '加载中...',
})
if(!type){
type = "POST";
}
wx.request({
url: appUrl,
data:appData,
header: {
'content-type': 'application/json'
},
method: type,
dataType: "json",
success: callback, //成功回调
fail: function (res) { },
complete: function (res) {
},
})
}
}

 

// 全局请求
request: function (appUrl, appData, callback, type) {
wx.showLoading({
title: '加载中...',
})
if (!type) {
type = "POST";
}
wx.request({
url: appUrl,
data: appData,
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: type,
dataType: "json",
success: callback, //成功回调
fail: function (res) { },
complete: function (res) {
},
})
},

posted on 2018-03-17 15:23  再胖十斤就好  阅读(629)  评论(0编辑  收藏  举报

导航