javascript - PHP script does not accept GET/POST data from a client having AngularJS scripts -


i have client app sending json object server in php.

client side code:

 var jacc = json.stringify(acc);console.log(acc);  $http.post($rootscope.url+'signup.php',jacc)    .then(function(response){console.log(response.data);}); 

which works fine.

but @ server side

 $acc = $_post["jacc"];   $code = $_post["code"];//received later   if($acc){      echo 1;//this thing never echoed.   }   elseif ($code  && matchcode($code)){     if(addacc($acc))         echo 1;  } else echo 0 ." failed"; die(); 

the output @ console "0 failed". tried changing post request httpbin.org/post works well. problem php script. tried var_dump($_post) returns null value.

your javascript code should :

var params = { jacc : json.stringify(acc) }; // or var params = acc; if acc object "jacc" property $http.post($rootscope.url+'signup.php', params)    .then(function(response){        console.log(response.data);    }); 

your error try post "string" when need post object key:value.


Comments