i having difficult time parsing json below using jquery.
{ "client": [{"clientid": "0000000001", "name": "valdez gilberto jr", "phone": "(956)542-8148" , "medactid": "10", "gender": "m", "division": "wp", "address": "1905 illinois ave n", "class": "", "citystate": "brownsville tx 78521-6732" } , {"clientid": "0000000002", "name": "salazar olga f", "phone": "(956)546-3909" , "medactid": "100", "gender": "f", "division": "mp", "address": "route 8 box 626 (san pedro)", "class": "", "citystate": "brownsville tx 78520" } ]}
been using code below no avail, keep getting undefined errors "data" being called via ajax:
var obj = json.parse(data); for(var = 0; < obj.length; i++){ alert(obj[i].client.name) }
have tried following -->
$.each(obj, function(key,value) { alert(value.client.name); });
thanks in advanced! diego
you trying iterate object, can't that. want iterate trough array in object, keyed client
try this:
for(var = 0; < obj.client.length; i++){ console.log(obj.client[i].name) }
Comments
Post a Comment