I'm trying to save spreadsheet data to json file. I use the following code. When i run this code nothing happens, and developer web console says 'no element found'. I'm using handsontable 0.29 Please help me with the working code. Your help is much appreciated.
js Code
Handsontable.Dom.addEvent(save, 'click', function() {
// save all cell's data
ajax('save.php', 'POST', {data: hot.getData()}, function (res) {
});
});
save.php
<?php
$myFile = "save.json";
$fh = fopen($myFile, 'w');
$stringData = $_POST["data"];
fwrite($fh, json_decode($stringData));
fclose($fh);
?>
js code
Handsontable.Dom.addEvent(save, 'click', function() {
ajax('save.php', 'POST', 'value='+JSON.stringify({data : hot.getData()}), function (res){
});
});
save.php
<?php
$stringData = $_POST["value"];
$myFile = "general.json";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $stringData);
fclose($fh)
?>
This works perfectly. Hope it would help someone else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.