In the console I can only see succes and $scope.data.username prints nothing. And a second question: In my php do i need to send status and status_massage? why?
in my js:
$scope.register = function register() {
$http.post('.../api/user.php', {username: $scope.user.username, password: $scope.user.password, func: 'register'}).
success(function(data, status, headers, config) {
console.log('succes');
$scope.data = data;
console.log($scope.data.username);
}).
error(function(data, status, headers, config) {
console.log('error');
});
};
In postman it wil return
{
"status": 200,
"status_message": "OK",
"data": {
"username": "smith99"
}
}
And my php script does:
$response['status'] = 200;
$response['status_message'] = "OK";
$response['data'] = array(
'username' => $user
);
$jsonResponse = json_encode($response);
echo $jsonResponse;