我可以获得“名称”值,但不能获得“订单”,似乎订单是作为对象而不是数组返回的?
json.json
[{ "ID":"23",
"LastName":"Moe",
"FirstName":"Ronnie",
"Orders":[{"OrderNumber":"11","ItemNumber":"22"},
{"OrderNumber":"33","ItemNumber":"44"}]}]
我的HTML.html
$.getJSON('json.json',
{},
function (data) {
$.each( data, function ( i, val ) {
var lastname=this.LastName;
var firstname=this.FirstName;
var orders=this.Orders;
$.each(data.Orders, function(property, value) {
alert(property + "=" + value);
//Insert the data to HTML page
$(".title").append('<li>'+lastname+', '+firstname+' >'+'</li>');
$(".title").append('<li>'+orders+'</li>');
});
});
})
});