[問題] 有關JSON的問題

看板Ajax作者 (ask)時間16年前 (2009/01/21 02:10), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
我想迴圈跑出a.json的全部資料 不過他都只能跑出第二筆資料= =" ================================== a.json: { 'yahoo': { "id": '123', } }, { 'google': { "id": '456', } } =================================== index.php: $.getJSON('a.json', function (data){ $('div #box').empty(); $.each(data, function (entryIndex, entry){ var html = entry['id']; $('div #box').append(html); }); =================================== 我寫這樣他只能讀到第二個id=456 = =" 而且是只能直接讀id 我寫成"yahoo": "123" 然後entry['yahoo'] 這樣的話會變成undefined 不知道是哪裡出問題!? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.204.112 ※ 編輯: askq 來自: 140.115.204.112 (01/21 02:13)
文章代碼(AID): #19TXEZ6H (Ajax)
討論串 (同標題文章)
文章代碼(AID): #19TXEZ6H (Ajax)