AngularJS - request Do not pass parameter

0

My code is this, but in the php code I do not get the ref parameter ... What can it be?

$http({
         method: 'POST',
         url:  '../assets/php/client/PHP.php',
         data: {ref: 'dataTableLoad'}
         }).then(function (response) {// on success
         //alert(response.data);
         console.log(response.data);
         $('#dataTableTboody').html(response.data);},
         function (response) {
         console.log(response.data,response.status);
         }); 
My php ecebe as follows:

if (isset($_POST['ref']) && $_POST['ref'] != '') {
    init($_POST['ref']);
} else {
    $data['response'] = -1;
    echo json_encode($data);
    exit;
}
It only returns me -1 Thank you     
asked by anonymous 17.04.2017 / 03:41

2 answers

1

if (isset($_POST['data']->ref) && $_POST['data']->ref != '') {
    init($_POST['data']->ref);
} else {
    $data['response'] = -1;
    echo json_encode($data);
    exit;
}
    
18.04.2017 / 18:42
1

You are passing the string literal 'dataTableLoad' to the server.

I imagine you want to pass the value of dataTableLoad . Try this:

$http({
     method: 'POST',
     url:  '../assets/php/client/PHP.php',
     data: {ref: dataTableLoad} // Perceba que retirei as aspas simples.
    
17.04.2017 / 03:47