-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