微信小程序的POST和GET请求方式的header区别

1.post请求:

wx.request({

        url: 'https://m.***.com/index.php/Home/Xiaoxxf/make_order',

        header: {

          "Content-Type": "application/x-www-form-urlencoded"

        },

        method: "POST",

        data: { is_home: that.data.is_home, openid: wx.getStorageSync('openid'), data_name: e.detail.value.data_name },
      success: function (res) {
       //...
     
   }
})

2.GET请求

wx.request({
    url: 'https://m.***.com/index.php/Home/Xiaoxxf/getStory',
    data: {
      page: page
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT  
    // header: {}, // 设置请求的 header  
    header: {
      'Content-Type': 'application/json'
    },
    success: function (res) {
      console.log(res.data)
      that.setData({
        list: res.data          //返回二维数组
        // views: res.data[0].views,     //查看数
        // praise: res.data[0].praise    //点赞数
      })
      page++;
    }
 })

 

posted @ 2017-06-29 16:13  PHP急先锋  阅读(20321)  评论(0编辑  收藏  举报