0

I try to send a handsontable table data using $http POST with Angulars.js The code below:

 var $container = $("div#table");         
 var handsontable = $container.data('handsontable');
 $scope.saveData = function() {
                $http.post('save.php', {'data':handsontable.getData()}).success(function(res,status) {
                      if (res.result === 'ok') {
                        console.log('Data saved');
                      }
                      else {
                        console.log('Save error');
                      }
                });
 }

But I get a 'Save error' with

Undefined index: data in <b>C:\xampp\htdocs\angular\save.php

I the development tool in Chrome I get Request payload of this form:

{"data":[[fdf,gsgg,gsg,null,null,null],[sgsg,sgg,sgg,ggs,null,null]]}

I changed parameters in $http.post to get it work but no solution, Thank you to give some advices!!!

Alex
  • 97
  • 1
  • 4
  • 15

1 Answers1

0

I finally found a solution in here : [How to retrieve Request Payload

Instead of retrieving the data in this way

$values=$_POST['data'];

I fetch in this way:

$request_body = file_get_contents('php://input');
Community
  • 1
  • 1
Alex
  • 97
  • 1
  • 4
  • 15