所以我能夠成功地從我的JSON對象中提取數據,我遇到的問題是數據被四次重複。有人能告訴我爲什麼會發生這種情況嗎?我從來沒有見過這個。這裏是JS:刪除重複的JSON對象
jQuery(function() {
jQuery.getJSON(NewConvData, function(data){
var channelHTML = ''
jQuery.each(data, function(i){
console.log(data);
for (var i in data.results) {
channelHTML += '<tr><td class="tg-yw4l">' + data.results[i].call_mine_status + '</td><td class="tg-yw4l">' + data.results[i].cdr_source + '</td><td class="tg-yw4l">' + data.results[i].tracking_number + '</td><td class="tg-yw4l">' + data.results[i].disposition + '</td><td class="tg-yw4l">' + data.results[i].duration + '</td><td class="tg-yw4l">' + data.results[i].external_id + '</td><td class="tg-yw4l">' + data.results[i].id + '</td><td class="tg-yw4l">' + data.results[i].is_outbound + '</td><td class="tg-yw4l">' + data.results[i].ouid + '</td><td class="tg-yw4l">' + data.results[i].repeat_call + '</td><td class="tg-yw4l">' + data.results[i].caller_id + '</td><td class="tg-yw4l">' + data.results[i].calldate + '</td><td class="tg-yw4l">' + data.results[i].ringto_number + '</td><td class="tg-yw4l"><a href="' + data.results[i].file_url + '">Recorded Call</a></td></tr>';
}
});
jQuery('#conv_table').append(channelHTML);
});
});
這裏是Fiddle link
你要做'的jQuery( '#conv_table')。空()''之前的append()' –
你有2個循環'each'和'for'都檢查https://jsfiddle.net/cmw3co4s/3/ –