-5
我的功能是從api中提取信息,然後將其放入表格中。由於某種原因,此功能不起作用。爲什麼我的javascript功能不能正常工作
這是我的函數:
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 fuigure值(socCode)到最後它會在線提供這些數據,然後返回到表格主體
試着解釋什麼'不工作',有心靈感應的人正在休息。 –
你期望它做什麼?什麼部分不起作用。你也需要有一個更具體的標題,然後這個。 –
什麼是'socCode'? – putvande