小程序对接php接口接收数据

来源:互联网 发布:ipad读书软件推荐 编辑:程序博客网 时间:2024/06/05 16:44

小程序js传值:

wx.request({          url: 'test.php', //仅为示例,并非真实的接口地址          method: "POST",          header: {              //传输接收数据的头(!!!)            'content-type': 'application/x-www-form-urlencoded'          },          data: {            x:'x'          },          success: function (res) {            console.log(res.data)            if (res.data==1){              that.data.isCode=true              wx.showToast({                title: '验证码',                icon: 'success',                duration: 2000              })            }else{              wx.showToast({                title: '验证码错误',                icon: 'success',                duration: 2000              })            }          }        })

php接收数据:

$_POST['X']//接收值,并进行后续数据处理