request中data参数不能传到后台
发布于 6 年前 作者 asun 18916 次浏览 来自 问答

wx.request({

url: config.url_api + '/user/Basicdata/getPhoneTypeList',

data: {lon:lon,lat:lat},

method: 'POST',

dataType:'json',

header: {

'content-type''application/json'

},

success: function (res) {

console.log(res.data)

}

})


后台数据可以返回,但是data中的参数传不到后台,求大神指导下

3 回复

 1 将header改成 application/x-www-form-urlencoded

 2 data 要写成 ‘a=b&c=d’ 的形式,根据你自己的数据拼接

header里的content-type改成

application/x-www-form-urlencoded

试试

  • 对于 header['content-type'] 为 application/json 的数据,会对数据进行 JSON 序列化

  • 对于 header['content-type'] 为 application/x-www-form-urlencoded 的数据,会将数据转换成 query string 

回到顶部