後不確定這裏的JSON字符串的示例:入門JSON解析的jQuery
{
"table": {
"tfoot": "Footer",
"tr0": [
{
"form": "formData",
"td": "Content"
}
]
}
}
而jQuery代碼我使用解析它:
$.ajax({
type: 'GET',
url: source,
dataType: 'json',
success: function (data) {
$.each(data, function() {
$.each(this, function(key, value) {
switch (key) {
case "tfoot":
alert(value) // access to this node works fine
break;
default:
alert(value.td) // this is undefined
break;
}
});
});
}
});
我嘗試了用CONSOLE.LOG鉻和我可以看到每個節點和數據是好的。任何人都有線索如何訪問「表單」或「TD」節點?
[]表示它的一個數組變量。所以你應該有另一個循環tr0或只使用tr0 [0]。 – arunes
http://stackoverflow.com/a/5514133/1288 http://stackoverflow.com/a/13586208/1288 –