小程序 wx.request ajax示例

简单示例 

https://developers.weixin.qq.com/miniprogram/dev/api/network-request.html

wx.request({
      method: 'POST',
      url: 'http://localhost:3011/wx/app/xindai/login',
      data: {
        userName: '13713332652',
        pwd: '123456.a',
        openId: 'oRsEC1ualLIvMV6E9-IHmZj-ZAQU' // 这个openid无论是什么接口都是必填的,而这个openid在服务号是从后端给我的,在小程序是由我们前端自己去获取的。
      },
      header: {
        'content-type': 'application/json',
        'token': '', // 登录 注册 忘记密码 之后会返回一个token,其他需要登录才调用的接口必须带这个token参数
        'Authorization': Authorization,
        'app':'WX'
      },
      success: function (res) {
        console.log(res.data)
      }
    })

原文地址:https://www.cnblogs.com/CyLee/p/8879680.html