I'm trying to access data in a multi-level AJAX response sent by PHP (WP). I've read other q's on the topic that say I need to iterate through the result so I am trying this:
$j.each(result[0], function(key , value){
// key, value
$j.each(value, function(k , v){
k,v
})
})
...which gives me the below in console:
I need to access just the values of each array so that they end up like this:
["2017-12-16", 128],
["2017-12-17", 105],
["2017-12-18", 76],
["2017-12-19", 107],
["2017-12-20", 93],
["2017-12-21", 46]
What I don't understand is after going down to a second .each why the result is the same as the first .each (both are same as image above). Could do with pointing in the right direction please. Many thanks.
Update I made the result array I wanted into an object and accessed it as follows:
obj = result[0];
$j.each( obj, function( key, value ) {
'["'+value[0]+'",', value[1]+'],'
})
...but this all became a moot point anyway as I was trying to add rows to a Google Chart and didn't need to iterate I just added the obj array and all was good.
