0

This is my Angular js Function

 $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");

                });


  };

This is my Zend Framework Controller Function .

 public function accountinfosaveAction(){
        $data = $this->getRequest()->getPost(); 
       print_r($data);// not working 
       print_r($_POST);// not working  
}

The problem is I want to access the data(uname,pswd,email) I sent from Angular Js using $http.post function to zend framework .

If I use $.ajax function it works fine . But $http.post Does not work . Please help me out.

2 Answers2

0

First of all, check post url is correct or not using test echo in function or a contructor

Try like this way,

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');
   }
);
Ranjith
  • 2,779
  • 3
  • 22
  • 41
0

you can use this to get post request $postdata = file_get_contents("php://input");

RamThakur
  • 100
  • 9
  • Worked for me print_r($postdata) Gives the post result . Thanks . – Vikrant Vir Bhalla Jan 13 '15 at 06:41
  • yeah, I found another post that mentions angular encodes the data as json rather than what php expects. http://stackoverflow.com/questions/19254029/angularjs-http-post-does-not-send-data – Scott May 11 '15 at 22:09