【发布时间】:2012-06-05 14:44:10
【问题描述】:
将用户在 jQuery Handsontable 中输入的数据上传回服务器以保存到数据库中的最佳方法是什么?
现有的onChange 回调似乎非常冗长,无法使用 AJAX 保存输入数据,尤其是当用户在现有数据行上方插入新数据行时。
在使用 Handsontable 或 jQuery
这里是full code 使用 jQuery 循环输入数据并以 JSON 格式转储到文本框中,然后提交到服务器。这个过程看起来很难看。寻找更清洁的方式..
$('#btnGo').click(function() {
var rowList = new Array();
$("table tr").each(function() {
var colList = new Array();
$("td", this).each(function() {
colList.push($(this).text());
});
rowList.push(colList);
});
$('#simple').val(JSON.stringify(rowList));
console.log(rowList);
});
【问题讨论】:
标签: javascript jquery spreadsheet handsontable