我对 jQuery 和 JSON 非常陌生。我需要解析以下格式的 JSON,以便填充 html 表 tbody:
{"response":[["name0","id0","amt0"],["name1","id1","amt1"]]}
但我不知道如何访问它们,所以通过以下方式获取 html 表:
header1 header2 header3
name0 id0 amt0
name1 id1 amt1
最佳答案
未经测试,但可能类似于:
var jsondata=$.parseJSON('{"response":[["name0","id0","amt0"],["name1","id1","amt1"]]}');
$.each(jsondata.response, function(i, d) {
var row='<tr>';
$.each(d, function(j, e) {
row+='<td>'+e+'</td>';
});
row+='</tr>';
$('#table tbody').append(row);
});
关于jquery - 如何将json数组数据附加到html表tbody中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12694135/