extract item from a multi dimensional array using jquery-Collection of common programming errors

I am using jQuery with jqgrid and I wanted to use few value from the edit results. The result of the edit is a multidimensional array. For some reason I can only alert up to the second child, the result goes undefined if i go any further.

The main array variable is postdata and if i have to iterate this using jQuery’s .each() function, I get these:

(item : value) format. the number is for the order of appearance

1 readyState : 4

2 setRequestHeader : function({....}) 
..
..
..
21 responseText : Array (
        [id] => 364
        [oper] => edit
        [note] => editing
        [client] => raha
   )

My intention is to get the value of id but if i have to alert the array outside the .each() function using this:

alert(postdata['responseText']['id'])

The alert result is undefined. If I removed the ['id'], it shows the entire responseText array (same with number 21).

How do I accomplish this task? many thanks.

SOLVED! Thanks to @Felix for the idea and to @Jasper for suggesting about the console.log.

The result of the jqGrid responseText is in double quotes, which makes it a string. I managed to solve this using the .split() function, two splits to be exact. First splitting it by '\n' and then by '=>'. I finally got what I wanted.

Thanks all

  1. If you can log the postdata variable and post the whole variable it would be much easier to give you advice (console.log(postdata);). That being said perhaps responseText is an array of objects in which case you would need to access its data like this:

    alert(postdata['responseText'][0]['id']);
    

Originally posted 2013-11-09 21:21:17.