Javascript 使用handsontable将数据保存到json文件

Javascript 使用handsontable将数据保存到json文件,javascript,php,json,ajax,handsontable,Javascript,Php,Json,Ajax,Handsontable,我正在尝试将电子表格数据保存到json文件。我使用以下代码。当我运行这段代码时,什么也没发生,开发者web控制台说“找不到元素”。我正在使用handsontable 0.29,请帮助我了解工作代码。非常感谢你的帮助 js代码 Handsontable.Dom.addEvent(save, 'click', function() { // save all cell's data ajax('save.php', 'POST', {data: hot.getData()}, fun

我正在尝试将电子表格数据保存到json文件。我使用以下代码。当我运行这段代码时,什么也没发生,开发者web控制台说“找不到元素”。我正在使用handsontable 0.29,请帮助我了解工作代码。非常感谢你的帮助

js代码

Handsontable.Dom.addEvent(save, 'click', function() {
    // save all cell's data
    ajax('save.php', 'POST', {data: hot.getData()}, function (res) {
    });
});
Handsontable.Dom.addEvent(save, 'click', function() {

    ajax('save.php', 'POST', 'value='+JSON.stringify({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);
?>
<?php

    $stringData = $_POST["value"];

    $myFile = "general.json";
    $fh = fopen($myFile, 'w') or die("can't open file");

    fwrite($fh, $stringData);
    fclose($fh)
?>

jscode

Handsontable.Dom.addEvent(save, 'click', function() {
    // save all cell's data
    ajax('save.php', 'POST', {data: hot.getData()}, function (res) {
    });
});
Handsontable.Dom.addEvent(save, 'click', function() {

    ajax('save.php', 'POST', 'value='+JSON.stringify({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);
?>
<?php

    $stringData = $_POST["value"];

    $myFile = "general.json";
    $fh = fopen($myFile, 'w') or die("can't open file");

    fwrite($fh, $stringData);
    fclose($fh)
?>

可能的复制源:初学者先生!你和我的问题无关。无论如何,谢谢你的回答。我想办法。