I have a relatively simple POST request in angular...
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");
});
And my php code that receives the data is the following...
$postdata = file_get_contents('php://input');
$request = json_decode($postdata);
header('Content-Type: application/json');
echo json_encode($request);
All I am doing is sending data, then sending it back in the response to check if it worked.
The connection is made, and console prints out a status of 200, but when I console.log(data), I get a value of null. Why am I not able to receive the data?
var_dump($postdata)to see what got received on the server?