1

我正在尝试从.json文件中保存和检索handson表中的数据以保存我拥有的数据

$('button[name=save]').click(function () {
  $.ajax({
    url: "json/load.json",
    data: {
      "data": handsontable.getData()
    }, //returns all cells' data
    dataType: 'json',
    type: 'POST',
    success: function (res) {
      if (res.result === 'ok') {
        alert('Data saved');
      }
      else {
        alert('Save error');
      }
    },
    error: function (xhr, err) {
      alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
    }
  });
});

但这不会保存数据获取error status:6,当尝试打印错误时。我不知道使用 json 和 jquery。我该如何正确地做到这一点?

4

0 回答 0