Javascript object to PHP -
i posting javascript objects php backend not able retrieve data.
i posted java-script object:
{"name":"mastermold"}
i trying access name this:
$name= $_post["name"];
the error is:
{"error":{"type":"errorexception","message":"undefined index: name","file":"c:\program files (x86)\ampps\www\app\controllers\journalscontroller.php","line":34}}
savemongojournal=function(thejournal,dothis) { journalroute="http://localhost/public/journals" $http.post(journalroute,thejournal).success(dothis); }; $scope.clicky= function(){ savemongojournal( {name: "mastermold"},alertreply); }; $_post['name'];
you may try (check this answer)
$data = json_decode(file_get_contents("php://input")); echo $data->name;
Comments
Post a Comment