我是angularjs的新手,在将记录保存到数据库时遇到了一些问题。它在我的php中说Undefined property stdClass::$passw
。这是我的代码:
$scope.get_admin = function(){
$http.get('query?action=nimdateg', {})
.then(function(response){
$scope.name = response.data.split(',')[0];
$scope.uname = response.data.split(',')[1];
})
.catch(function(response){
$scope.showToast('Failed to retrieve admin data: ' + response.data);
});
};
$scope.get_admin();
$scope.account_update = function(isValid){
if(isValid){
$http.post('query?action=tnoucca_etadpu',{
'name': $scope.name,
'username': $scope.uname,
'passw': $scope.passw
})
.then(function(response){
alert(response.data); //says "undefined property stdClass::$passw"
})
.catch(function(response){
$scope.showToast("SYS_ERROR: " + response.data);
});
}
};
我的php:
if ($action == "tnoucca_etadpu") {
$data = json_decode(file_get_contents("php://input"));
$name = $data->name;
$uname = $data->username;
$pw = $data->passw;
}
我认为这是因为$scope.get_admin
的代码,因为我没有声明$scope.passw