3
  1. i have used angualr js and developing a mini app for crud operation i ma facing issue while i send a post request it shows posted value in fireug console as shown in image1 but while trying to same using $_REQUEST or $_POST it returns blank array

Explanation..

in product.js

app.controller('productsCtrl',function($scope,Data){ 
$scope.changeStatus=function(product){
        $scope.status = {};
        $scope.status.status = product.status=='Active' ? 'Inactive' : 'Active';
        //Data.put('http://localhost/angularCrud/products.php',$scope.status);
        Data.put('http://localhost/angularCrud/test.php',$scope.status);
    };
});

in data.js

app.factory('Data',['$http','$location',function($http){ 
    var obj={};
obj.put=function(q,param){ //console.log(data);
    //$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
      successData = $http.post(q,param).success(function(response){
        console.log(response);
        return response;
      });
};

    return obj;
}]);

enter image description here

enter image description here

please let me know how to access the posted value of status??

PRANAV
  • 629
  • 4
  • 13
  • 1
    obviously we're gona need more info on this, some code snippet, or more eplanation on the structure of the project, for all we know you could be setting the array to null somewhare in your program. – some_groceries Nov 30 '15 at 06:29
  • let me know what info you need.. – PRANAV Nov 30 '15 at 06:29
  • the part of the code that posts the request and parts where the post might be used and where its being displayed – some_groceries Nov 30 '15 at 06:31
  • 1
    as @deeznutz it will require your service call and php code to show up but also you can have a look @ http://stackoverflow.com/questions/15485354/angular-http-post-to-php-and-undefined – krish Nov 30 '15 at 06:33
  • @deez nuts question updated with description. – PRANAV Nov 30 '15 at 06:33
  • @krish link you gave same as i want thanks... – PRANAV Nov 30 '15 at 06:38

1 Answers1

2

I have also face same problem in my app.The solution i do is

$data = file_get_contents("php://input");  //Get all data of form
$request = json_decode($data); 

$request is an object array now use this like

$request->action  //Anything your data is
Sunil Pachlangia
  • 2,033
  • 2
  • 15
  • 25