Q:

angular $http post not working well

i try send post with $http to php,its working well but when i want to test if $_post['action'] == 'getPayments' then this not reponse nothing.
This is my $http post:
 var req = {
         method: 'POST',
         url: 'process.php',
         headers: {
           'Content-Type': 'json'
         },
         data: 'action=getPayments'
        }

        $http(req).then(function(req){
            console.log(req.data);
            $scope.bidslist = req.data;
        }, function(){

        });

And this is php:
$action = isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : '');

if ( !empty($action) ) {

    switch ( $action ) {

              case 'getPayments':     

                  some code goes here
                  echo json_encode($myArray);

              break;
     }
}

I can see it in debug console that this send post with action=getPayments but in php side its not recogonize the post only when i remove switch its working..
I don't have any errors just no response from php what is the issue?

A:

Try Content-Type to be application/json
var req = {
         method: 'POST',
         url: 'process.php',
         headers: {
           'Content-Type': 'application/json'
         },
         data: 'action=getPayments'
        }

        $http(req).then(function(req){
            console.log(req.data);
            $scope.bidslist = req.data;
        }, function(){

        });

