Actually.. looking @ that JSON again after Steven's post, the JSON
should be

{ "departments": [
   "department": {"ID": 1, "Name": "Physics"},
   "department": {"ID": 2, "Name": "Chemistry"},
   "department": {"ID": 3, "Name": "Biology"}
   ]
}

Pretty sure anyways... it's been a long day :-)


On Mar 26, 9:10 pm, Steven Yang <kenshin...@gmail.com> wrote:
> I think the problem is you have the "department" 3 times in the same hash
> object,so the last one overrides everything.
> you should change "departments" to an array and loop through it
>
>
>
> > > { "departments": {
> > >    "department": {"ID": 1, "Name": "Physics"},
> > >    "department": {"ID": 2, "Name": "Chemistry"},
> > >    "department": {"ID": 3, "Name": "Biology"}
> > > }}
>
> > > i tried
>
> > > $.each(json.departments.department, function(i, n) {
> > >       alert(i + " " + n);
> > > });

Reply via email to