我遇到了問題,試圖在我的JSON文件中獲取嵌套數據。在JSON中嵌套的數據
任何人都可以幫助我嗎?我正在嘗試創建一個megamenu。
$.getJSON("js/nav.json", function (data) {
$.each(data.navigation, function (i, navigation) {
var jsondata = "<li class='top-level'><a href='/" + this.link + "'>" + this.title + "</a></li>";
$.each(this.headingArray, function() {
alert(hello);
});
$(jsondata).appendTo("ul.nav");
});
});
});
,這裏是樣本JSON文件IM從
{
"navigation": [
{
"title": "Home",
"link": ""
},
{
"title": "Find your ski holiday",
"link": "#URLhere",
"headingArray": [
{
"heading": [
{
"title": "Destinations",
"link": "#URLhere",
"subheading": [
{
"title": "Andorra",
"link": "#URLhere"
},
{
"title": "Austria",
"link": "#URLhere"
},
任何幫助閱讀將不勝感激嗎?
演示 - http://dev.thirstythursdays.co.uk/menu-json3
你可以更具體一點*你的問題是什麼*? – Friederike 2013-04-22 14:48:26