0
這是我的HTML。如何在URL和輸出檢查ID只用的getJSON
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
<script>
$(function() {
var people = [];
$.getJSON('test.json', function(data) {
$.each(data.person, function(i, f) {
var tblRow = "<tr>" + "<td>" + f.ID + "</td>" +"<td>" + f.Destination + "</td>" +
"<td>" + f.SupplierName + "</td>" + "</tr>"
$(tblRow).appendTo("#userdata tbody");
});
});
});
</script>
</head>
<body>
<table id= "userdata" border="2">
<thead>
<th>ID</th>
<th>Destination</th>
<th>SupplierName</th>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
這是我test.json文件
{
"person" : [
{
"ID" : 100,
"Destination" : "brisbane",
"SupplierName" : "Hilton Brisbane",
},
{
"ID" : 101,
"Destination" : "brisbane",
"SupplierName" : "Hotel Grand Chancellor Brisbane",
},
{
"ID" : 102,
"Destination" : "brisbane",
"SupplierName" : "Park Regis North Quay",
}
]
}
我試圖做
輸出工作正常。但這是我想要做的。
我的網站看起來像www.website.com?deal=100
我要尋找的ID,在「交易」的參數,只輸出從JSON陣列的ID信息的結束。 JSON數組有一個具有相同ID的對象。你能幫忙嗎?
謝謝SOOO了! – nasty