Javascript Angular Js$http.post方法无法访问Zend Framework中的数据
这是我的角js函数Javascript Angular Js$http.post方法无法访问Zend Framework中的数据,javascript,php,angularjs,zend-framework,Javascript,Php,Angularjs,Zend Framework,这是我的角js函数 $scope.submitform = function () { $http.post('http://localhost:90/vendor/dashboard/accountinfosave/', {'uname': 'vikrant', 'pswd': '111', 'email': 'bhallavikrantvir@gmail.com'} ).success(function(data) {
$scope.submitform = function () {
$http.post('http://localhost:90/vendor/dashboard/accountinfosave/',
{'uname': 'vikrant', 'pswd': '111', 'email': 'bhallavikrantvir@gmail.com'}
).success(function(data) {
alert("success");
}).error(function(data) {
alert("error occured");
});
};
这是我的Zend框架控制器函数
public function accountinfosaveAction(){
$data = $this->getRequest()->getPost();
print_r($data);// not working
print_r($_POST);// not working
}
问题是我想访问我使用$http.post
函数从Angular Js发送到zend framework的数据(uname、pswd、email
)
如果我使用$.ajax
函数,它工作得很好。但是$http.post
不起作用。
请帮助我。首先,检查帖子url是否正确,是否使用
函数中的testecho
或构造函数
这样试试看
var request = $http({
method: "post",
url: "http://localhost:90/vendor/dashboard/accountinfosave/",
data: {
uname : 'vikrant',
pswd : '111',
email : 'bhallavikrantvir@gmail.com'
}
});
request.success(
function( data ) {
$scope.data = data;
alert('success');
}
);
您可以使用它来获取post请求
$postdata=文件获取内容(“php://input");我也做了echo。它将进入zend函数,但我无法访问那里的$\u POST数据。为我工作的print\r($postdata)将给出POST结果。谢谢。是的,我发现另一篇文章提到angular将数据编码为json,而不是php所期望的。