我想将JSON数据添加到现有数据表中。
JSON数据如下所示:
[
["Trident","Internet Explorer 4.0","Win 95+","4","X","X"],
["Trident","Internet Explorer 4.0","Win 95+","4","X","X"],
["Trident","Internet Explorer 4.0","Win 95+","4","X","X"],
["Trident","Internet Explorer 4.0","Win 95+","4","X","X"]
]
我试过了:
$('#' + tab + '_table').dataTable().fnAddData(data);
data
持有JSON数据。
因为它只添加了一行,所以似乎有任何错误:
答案 0 :(得分:5)
看起来您要求dataTables将原始JSON数据添加到您的表中。您应首先使用JSON.parse()
解析它并添加生成的Javascript数组。
var jsdata = JSON.parse(data);
$('#' + tab + '_table').dataTable().fnAddData(jsdata);