我试图使用来自对象的数据填充几个lement类:
HTML:
$this->Order->OrderItem
使用Javascript:
<table>
<tr>
<td><span class="hoursspan"></span></td>
<td><span class="partspan"></span></td>
</tr>
<tr>
<td><span class="hoursspan"></span></td>
<td><span class="partspan"></span></td>
</tr>
<tr>
<td><span class="hoursspan"></span></td>
<td><span class="partspan"></span></td>
</tr>
<tr>
<td><span class="hoursspan"></span></td>
<td><span class="partspan"></span></td>
</tr>
</table>
它在fiddle中运行得很好,但在我的环境(SharePoint 2013 on Premises)中,我不断获得var finalData = [{
"issue": "A",
"hours": 79,
"partcipantes": 33
}, {
"issue": "B",
"hours": 16,
"partcipantes": 10
}, {
"issue": "C",
"hours": 12,
"partcipantes": 10
}, {
"issue": "D",
"hours": 5,
"partcipantes": 8
}];
for (var w = 0; w < finalData.length; w++) {
document.getElementsByClassName("hoursspan")[w].innerHTML = finalData[w].hours;
document.getElementsByClassName("partspan")[w].innerHTML = finalData[w].partcipantes;
}
。我不知道还有什么可以造成这个问题?
谢谢。