0
我想让表列可编辑,但我不是很熟悉JS,所以有人可以给我看光吗? 要保存文件,我找到了一个很棒的jquery插件。 但对于编辑和保存我没有找到一个方法来做到这一点...做一个表列可编辑并保存在一个文件
$(document).ready(function() {
/* Init DataTable */
var table2Edit = $('#table2Edit').dataTable();
// Save table in json file
var table = $('#table2Edit').tableToJSON();
$.ajax({
type : "POST",
url : "ajax.php",
dataType : 'json',
data : {
json : JSON.stringify(table) /* convert here only */
}
});
});
服务器端:
$json = $_POST['json'];
if (json_decode($json) != null) { /* sanity check */
$file = fopen('myTable.json','w+');
fwrite($file, $json);
fclose($file);
var_dump($file);
}