php - Angularjs $http post didn't pass param? -


i've been debugging hours. tried set header etc no luck!

my controller

 $http({     url: 'http://myphp.php/api.php',     method: "post",     data: {'wtf':'test'} }) .then(function(response) {         console.log(response);     },      function(response) { // optional         // failed     } ); 

and php

<?php echo "test";  echo $_post["wtf"]; ?> 

in network tab how

enter image description here

not sure what's wrong man, exhausted, i'm stuck hours! why $_post['wtf] didn't echo?

$http serializing data json in request body php's $_post looking key/values parsed posted form data. these 2 different mechanisms posting data need choose 1 , use mechanism on both sides.

you have 2 options solve this:

  1. in php code, parse request body json data , use object retrieve data. see this stackoverflow question more information.

  2. modify $http request post data form data. see this stackoverflow question more information.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -