Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angular Js$http.post方法无法访问Zend Framework中的数据_Javascript_Php_Angularjs_Zend Framework - Fatal编程技术网

Javascript Angular Js$http.post方法无法访问Zend Framework中的数据

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) {

这是我的角js函数

 $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是否正确,是否使用
函数中的test
echo
构造函数

这样试试看

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所期望的。