javascript - Angularjs $http POST request empty array -


the following $http request executes successfully, yet php script on other end receives empty $_post array when should receive 'test' , 'testval.' ideas?

$http({     url: 'backend.php',     method: "post",     data: {'test': 'testval'},     headers: {'content-type': 'application/x-www-form-urlencoded'}     }).success(function (data, status, headers, config) {     console.log(data);      }).error(function (data, status, headers, config) {}); 

if wan send simple data, try this:

$http({     url: 'backend.php',     method: "post",     data: 'test=' + testval,     headers: {'content-type': 'application/x-www-form-urlencoded'}     }).success(function (data, status, headers, config) {         console.log(data);      }).error(function (data, status, headers, config) {}); 

and php part shoul this:

<?php     $data = $_post['test'];     $echo $data; ?> 

it working me.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -