Trying to send Handsontable table data using $http POST with Angular.js has been a bit of a struggle for me. Here's the code snippet:
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');
}
});
}
Unfortunately, I keep getting a 'Save error' along with an error message that reads:
Undefined index: data in <b>C:\xampp\htdocs\angular\save.php
Inspecting the Request payload in Chrome's development tool shows it in this format:
{"data":[[fdf,gsgg,gsg,null,null,null],[sgsg,sgg,sgg,ggs,null,null]]}
I've tried changing parameters in $http.post but haven't found a solution yet. Any advice would be greatly appreciated!