【发布时间】:2013-06-14 17:47:02
【问题描述】:
我的 JavasSript 发送请求:
var jax = new XMLHttpRequest();
jax.open("POST", "http://localhost/some.php", true);
jax.setRequestHeader("Content-Type", "application/json");
jax.send(JSON.stringify(jsonObj));
jax.onreadystatechange = function() {
if(jax.readyState === 4) { console.log(jax.responseText); }
}
现在我的 php 所做的只是:
print_r($HTTP_RAW_POST_DATA);
print_r($_POST);
原始帖子数据的输出是对象字符串,但帖子数组为空。
{"name" : "somename", "innerObj" : {} ... }
Array
(
)
我需要为 $_POST 变量以正确的格式获取它,而 jquery 不是一个选项。
【问题讨论】:
-
你试过
file_get_contents('php://input')吗?