作者askq (ask)
看板Ajax
标题[问题] 有关JSON的问题
时间Wed Jan 21 02:10:42 2009
我想回圈跑出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)