0
我打電話給$ http.post函數,但無法獲取另一端的數據,調用成功,但無法檢索我的PHP腳本中的數據
AngularJS:
var data = {
firstname: $scope.first_name,
lastname: $scope.last_name,
email : '[email protected]',
user : userID
};
var config = {
headers : {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
}
}
$http.post('http://xxx-env.us-east-1.elasticbeanstalk.com/apipost/updateusersetting/user/'+userID, data, config).success(function (data, status, headers, config) {
alert('yay'); // this works and gets called
})
.error(function (data, status, header, config) {
});
服務器端PHP:
$data = json_decode(file_get_contents("php://input"));
$email = $data->email;
$user = $data->user;
$firstname = $data->firstname;
$lastname = $data->lastname;
也嘗試在$ HTTP每個崗位這一點,不工作要麼
$email = $_POST['email'];
$user = $_POST['user'];//$data->user;
$firstname = $_POST['firstname']; //$data->firstname;
$lastname = $_POST['lastname']; ;//$data->lastname;
請問您可以發佈$ _POST的var_dump嗎? – atefth