来自POST请求NULL/php的响应

来自POST请求NULL/php的响应,php,angularjs,Php,Angularjs,我有一个相对简单的后角要求 var data = $.param({ clientID: '329272' }); var config = { headers : { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;' } } $http.post('./server.

我有一个相对简单的后角要求

var data = $.param({
            clientID: '329272'
        });

var config = {
            headers : {
                'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
            }
        }
    $http.post('./server.php', data, config)
        .success(function (data, status, headers, config) {
            console.log(status);
            console.log(data);
        })
        .error(function (data, status, header, config) {
            console.log("nope");
        });
我接收数据的php代码如下所示

$postdata = file_get_contents('php://input');
$request = json_decode($postdata);

header('Content-Type: application/json');
echo json_encode($request);
我所做的就是发送数据,然后在响应中发送回去,检查它是否有效

连接完成后,console打印出一个状态为
200
,但当我
console.log(data)
时,我得到一个值
null
。为什么我无法接收数据?

$。param()
未编码为json,因此服务器上的json解码($postdata)解析将失败

创建适合在URL查询字符串或Ajax请求中使用的数组、普通对象或jQuery对象的序列化表示

您可以使用
JSON.stringify
将javascript对象序列化为JSON。

完成了任何基本调试,如
var\u dump($postdata)
以查看服务器上收到了什么?