1
I want read a JSON in PHP received from a function $http.post()
from Angularjs, I’ve tried using json_decode()
and set up the header (both in PHP and Angular) but it didn’t work. PHP accuses it to be an undefined index, I tried to use var_dump and it returns NULL.
Angular
$http.post(path, $scope.meuJson, { headers: { 'Content-Type': 'application/json' } }).success(function(response) { ... })
PHP
header('Content-type: application/json'); $json = json_decode($_POST['meuJson']);
var_dump($_POST)
array(0) { }
OBS: I can see the data being sent as payload of my request by Network
of a
var_dump($_POST)
and add the result to your question– Erlon Charles
This return is not a json
– Erlon Charles
I don’t know anything about angular, but if you pass the value of
$scope.meuJson
, how would the framework know with which key this would be posted? As @Erloncharles suggested, edit the question with the output ofvar_dump($_POST)
to clarify this.– bfavaretto
Post the format of mdados you want to send, do not need to be exactly the data
– Erlon Charles