服务器上的代码如下:
Welcome <?php echo $_POST["fname"]; ?>!<br>
You are <?php echo $_POST["age"]; ?> years old.
小程序的代码如下:
wx.request({
url: 'https://*******/****/test.php',
data: { fname:'nail', age:'33'},
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header: {"Content-Type":"application/json"}, // 设置请求的 header
success: function(res){
console.log(res)
},
结果返回:
传过出的参数,没有抓出来。

'content-type':' application/x-www-form-urlencoded'
2楼正解,已经搞定,谢谢
可能是你的 php 不支持全小写的 Content-Type,我觉得这是开发者工具的 bug, 全转成小写是不规范的。