posted value shows in firebug but while try to access the same it shows blank array

Refresh

December 2018

Views

66 time

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??

1 answers

2

Я также сталкиваются с той же проблемой в моем app.The решении я сделать

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

$request является массив объектов теперь использует это как

$request->action  //Anything your data is