JSON
{
"form": {
"roles": {
"role": [
{ "name": "RoleB" },
{ "name": "RoleA" }
]
},
"rows":[
{
"id":"1",
"fields":{
"field":[
{
"fname":"Matt"
}
]
}
}
]
}
}
How can I access the value of fname using jquery?
This is what I’m doing —
jQuery.each(response.form.rows.fields.field, function(i, val){
alert(this.fname);
}
Watch out for those arrays….
response.form.rows[0].fields.field[0].fnameOr, in your case (and assuming there’s only one
rowselement):If there’s more than one element in
rows, you need a second loop:http://jsfiddle.net/mblase75/33H8L/