Reputation:
When using: -
$.getJSON("admin.php?format=json", { module: "data", action: "allBusinessUnitsByClientName", clientname : $('#client').val() }, function(json) {
$.each(json.items, function(i,item){
alert(i);
});
});
I get the following error in the Firebug console:-
a is undefined
a))();else c.error("Invalid JSON: "+a)...f(d)if(i)for(f in a){if(b.apply(a[f],
The Json being returned is in the following format: -
{"550":"Test 1","547":"Test 2","549":"Test 3"}
Upvotes: 1
Views: 198
Reputation: 630439
You're getting this because json.items
is undefined
here, you just want json
(your object being returned, which has no items
property), like this:
$.getJSON("admin.php?format=json", { module: "data", action: "allBusinessUnitsByClientName", clientname : $('#client').val() }, function(json) {
$.each(json, function(i,item){
alert(i);
});
});
Upvotes: 4