0
我的功能是從api提取信息,然後將其放入表格中。出於某種原因,此功能不起作用。從API創建表格
這是我的函數:
function getPayInfo(socCode) {
var apiurl = "http://api.lmiforall.org.uk/api/v1/ashe/estimatePay?soc=";
var apicall = apiurl + socCode;
$.get(apicall, function(data) {
$("#Pay tbody").html("");
$.each(data.years, function(i, e) {
var tablerow = $("<tr></tr>");
tablerow.append("<td>" + e.year + "</td>");
tablerow.append("<td>" + e.estpay + "</td>");
$("#Pay tbody").append(tablerow);
});
});
}
這就是我把它插入到表:
<div class="well table table-stripped">
<h4>Pay Information</h4>
<h5>Pounds per Week</h5>
<table id="Pay">
<thead>
<tr>
<th>Year</th>
<th>Estimate Pay</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
我預期的一年數據值返回到表。如果你在函數中使用了url並且添加了一個特定的4位數值(socCode)(例如5113),那麼它會在線提供數據,然後返回到表格主體。
什麼是返回/錯誤是什麼? – Dan