【发布时间】:2010-10-24 12:55:02
【问题描述】:
好的,我有一个如下所示的 json 输出:
{"Result" : [
{
"Id" : "5214",
"ParentReasonId" : "0",
"Description" : "Billing & Payment",
"SysName" : "Billing & Payment",
"SysCategory" : "Billing & Payment",
"ClientId" : "924",
"DispositionCount" : "6",
"IsActive" : true,
"ChildReasonCount" : "8",
"Attributes" : [],
"SortOrder" : "0",
"CreatedBy" : null
}
]
}
我想从中提取 id 和 description 的数据。
jQuery("#chained_child").cascade("#chained", {
ajax: { url: 'Customhandler.ashx?List=MyList' },
template: commonTemplate,
match: commonMatch
});
function commonTemplate(item) {
return "<option Value='" + item.Result.Id + "'>"
+ item.Result.Description + "</option>";
};
但是对于我的生活,我无法让它返回我正在寻找的价值。我知道这很无聊,但我正在碰壁。有人可以帮忙吗?
【问题讨论】:
-
我不认为是语法错误把你搞砸了?
-
当我把 alert(item.Result.Id) 我回来未定义。所以我不太确定。
-
该 JSON 是否从某处作为字符串返回?你确定它已经被评估成一个对象吗?通过 alert(typeof item) 查找;
标签: javascript jquery json