使用时: -
$.getJSON("admin.php?format=json", { module: "data", action: "allBusinessUnitsByClientName", clientname : $('#client').val() }, function(json) {
$.each(json.items, function(i,item){
alert(i);
});
});
我在Firebug控制台中收到以下错误: -
a is undefined
a))();else c.error("Invalid JSON: "+a)...f(d)if(i)for(f in a){if(b.apply(a[f],
返回的Json格式如下: -
{"550":"Test 1","547":"Test 2","549":"Test 3"}
答案 0 :(得分:4)
您收到此消息是因为此处json.items
为undefined
,您只需要json
(您的对象被返回,其中没有items
属性),如下所示:
$.getJSON("admin.php?format=json", { module: "data", action: "allBusinessUnitsByClientName", clientname : $('#client').val() }, function(json) {
$.each(json, function(i,item){
alert(i);
});
});