我返回了一个 JSON,我想获取 JSON 的最后 8 个元素并制作一个表格。该表按照我期望的方式构建,但结果值未定义。这是 getJSON 的代码,一个编辑后的返回和表格。
$.getJSON("loadloads.php", function(data){
[{
"value": {
"lineNumber": "258640",
"TypeId": "1",
"StopNumber": "1",
"ReferenceNo": "0002325063",
"LocationId": "3",
"SLN": "227311",
"LoName": "Elk GAF Materials Corp - Shafter",
"Type": "Shipper"
}
}, {
"value": {
"lineNumber": "258641",
"TypeId": "2",
"StopNumber": "2",
"ReferenceNo": "682383",
"LocationId": "205697",
"SLN": "227311",
"LoName": "RWC Building Products - Albuquerque",
"Type": "Consignee"
}
}
]
var table_obj = $('table');
$.each(data, function(index,value){
table_obj.append($('<tr><td>'+value.SLN+'</td><td >'+value.Type+'</td><td>'+value.StopNumber+'</td><td>'+value.LoName+'</td><td>'+value.ReferenceNo+'</td><td class="hide">'+value.TypeId+'</td><td class="hide">'+value.Locationid+'</td><td class="hide">'+value.lineNumber+'</td></tr>'));