我有我的網頁上這個HTML表,我想從這個JSON URL數據動態填充:http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item=1055使用JSON URL數據,以動態填充HTML表
老實說,我不知道的最好方式做到這一點,但從我發現的JSON模板似乎是我應該使用的。我找到了使用Javascript幫助將JSON數據轉換爲HTML的「Pure.js」(http://beebole.com/pure/)和「Mustache.js」(https://github.com/janl/mustache.js)。我無法弄清楚如何使用這些URL加載數據,這個例子都是使用靜態字符串。我可以/應該使用AJAX,jQuery來做到這一點嗎?來自JSON網址的數據每天都在變化。
我在HTML下面{...}的地方是,我想從URL中的數據加載到。
我會很感激,如果有人可以點我就如何做這個正確的方向,並希望我提供的代碼示例,以幫助我得到這個工作。
<div class="item-details">
<div>
<h5>
{item.name}
</h5>
<p>Aaaarrrghhh ... I'm a monster.</p></div>
<h6>Pricing Information:</h6>
<table>
<tbody>
<tr>
<th>Current guide price:</th>
<td>{item.current.price}</td>
</tr>
<tr>
<th>Today's Change:</th>
<td class="{item.today.trend}">{item.today.price}</td>
</tr>
</tbody>
<tr>
<th>30 Day Change:</th>
<td class="{item.day30.trend}">{item.day30.change}</td>
</tr>
<tr>
<th>90 Day Change:</th>
<td class="{item.day30.trend}">{item.day90.change}</td>
</tr>
<tr>
<th>180 Day Change:</th>
<td class="{item.day30.trend}">{item.day180.change}</td>
</tr>
</table>
</div>
</div>