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
Post a Comment