我通过jquery用行填充HTML tbody,它没有在浏览器中显示新行但是如果我尝试在chrome控制台中看到tbody内容它会向我显示html但它不会在浏览器中显示
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
function initTables() {
MergeObjects_ToArry(statsGroup.obamaFollowers.lang, statsGroup.trumpFollowers.lang, 'lang');
addRowToTable(statsGroup.mergedFollowers['lang'], "tblLanguageGroup");
MergeObjects_ToArry(statsGroup.obamaFollowers.timeZone, statsGroup.trumpFollowers.timeZone, 'timeZone');
addRowToTable(statsGroup.mergedFollowers['timeZone'], "tblTimeZone");
MergeObjects_ToArry(statsGroup.obamaFollowers.age, statsGroup.trumpFollowers.age, 'age');
addRowToTable(statsGroup.mergedFollowers['age'], "tblAgeGroups");
}
function addRowToTable(data, tblId) {
var rowHtml = '';
Object.keys(data).forEach(function (key, index) {
rowHtml += "<tr>";
rowHtml += '<td>' + key + '</td><td>' + data[key][0] + '</td><td>' + data[key][1] + '</td>';
rowHtml += "</tr>";
});
$("#" + tblId).find('tbody').append(rowHtml);
}
function MergeObjects_ToArry(obj1, obj2, keyName) {//obama , trump
var obama = jQuery.extend(true, {}, obj1);
var trump = jQuery.extend(true, {}, obj2);
Object.keys(obama).forEach(function (key, index) {
if (trump[key]) {//if key exists in small
obama[key] = [obama[key], trump[key]];// Merge values in ARRAY
}
else {
obama[key] = [obama[key], 'N/A']; // key is in only obj1 so add it in mergedObj
}
});
statsGroup.mergedFollowers[keyName] = obama;
//merge keys in trump not present in obama
}
TLDR: 我有来自api的数据,我试图填充三个html表,只有一个用新数据显示,另外两个在我检查控制台时有数据但是没有显示。
答案 0 :(得分:1)
您是否尝试评论添加图表'timeZoneChart'的行?你的api正在为timeZone发送数据?