Blogger Information
Blog 5
fans 0
comment 0
visits 3322
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
微信小程序 request请求
瞬间
Original
787 people have browsed it

/**

  * request请求

  * method: 请求方式

  * url: 请求地址

  * data: 要传递的参数

  * callback: 请求成功回调函数

  * errFun: 请求失败回调函数

  **/

  wxRequest(method, url, data, callback, errFun) {

    wx.request({

      url: url,

      method: method,

      data: data,

      header: {

        'content-type': method == 'GET' ? 'application/json':'application/x-www-form-urlencoded',

        'Accept': 'application/json'

      },

      dataType: 'json',

      success: function (res) {

        callback(res.data);

      },

      fail: function (err) {

        errFun(res);

      }

    })

  },


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post