So, i'm getting some json data and iterating over the result and populating a table based on the resulting values.
(所以,我要获取一些json数据并遍历结果,然后根据结果值填充表格。)
I actually want to populate two tables with the same results and have tried the following code: (我实际上想用相同的结果填充两个表,并尝试了以下代码:)
$.getJSON( "helpers.php", {
})
.done(function( rows ) {
$.each(rows, function() {
// populate the table
var row = $('<tr>');
var position = $('<td>').html(this.position);
var teamname = $('<td>').html(this.team);
var points = $('<td>').html(this.points);
row.append(position,teamname,points);
$('#table-one').append(row);
$('#table-two').append(row);
});
});
It works if I comment out either of the tables to append, so ie only appending to one or the other, but not both.
(如果我注释掉要附加的任何一个表,则它起作用,即仅附加到一个或另一个,而不是两个都附加。)
Not sure why this doesnt work, but any explanations and code fixes appreciated. (不知道为什么这不起作用,但是任何解释和代码修复都值得赞赏。)
ask by translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…