unemployment Posted June 2, 2011 Share Posted June 2, 2011 I have a json encoded array {"users":[{"row_id":"1","0":"Tom","1":"Cruise","2":"tomcruise","3":"1","4":"231","5":"10","6":"Old Lyme","7":"235","8":"532","9":"12"},{"row_id":"21","0":"mrs. tom","1":"cruise","2":"place","3":"0","4":null,"5":null,"6":null,"7":"6","8":"42","9":"0"}]} My javascript is... var search = eval('(' + resp + ')'); var search_wrap =[]; alert(search.length); When my function returns the json encoded array, my alert is undefined. Is this because my array is multidimensional? Quote Link to comment https://forums.phpfreaks.com/topic/238228-eval-makes-length-undefined/ Share on other sites More sharing options...
Adam Posted June 3, 2011 Share Posted June 3, 2011 The JSON specifies a parent "users" object: {"users":[ ... So you need to use search.users.length. Quote Link to comment https://forums.phpfreaks.com/topic/238228-eval-makes-length-undefined/#findComment-1224593 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.