我有 Postman(不能在 Chrome 中打开的那个),我正在尝试使用原始 JSON 发出 POST 请求。
在“正文”选项卡中,我选择了“原始”并使用此正文选择了“JSON(应用程序/json)”:
{
"foo": "bar"
}
对于我有 1 的标题,Content-Type: application/json
在 PHP 方面,我现在只是在做 print_r($_POST);
,我得到一个空数组。
如果我使用 jQuery 并且这样做:
$.ajax({
"type": "POST",
"url": "/rest/index.php",
"data": {
"foo": "bar"
}
}).done(function (d) {
console.log(d);
});
我得到了预期:
Array
(
[foo] => bar
)
那么为什么不使用 Postman 呢?
postman 截图:
和标题:
最佳答案
关于php - 使用 Postman 通过原始 JSON 发送 POST 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39008071/