jquery - .each() function showing first object 3 times, instead of all 3 objects -
a query of wordpress custom fields, generates array:
array ( [genre] => rock [concert_city] => new york [concert_date] => 01-16-2014 [start_time] => 8:00 pm ) array ( [genre] => jazz [concert_city] => chicago [concert_date] => 12-12-2013 [start_time] => 7:00 pm ) array ( [genre] => pop [concert_city] => los angeles [concert_date] => 11-16-2013 [start_time] => 8:00 pm )
this array stored in:
$array = array();
need data jquery.
$(document).ready(function() { var event = <?php echo json_encode($array) ?>; $.each(event,function( index, value ){ console.log(event); }); });
this shows me first object 3 times, instead of 3 objects. how can iterate across 3 objects?
and need change them index:value, value(concert_date) : value(concert_city), right i'm stuck getting first object in array 3 times, instead of 3 objects.
edit: ran console.log(value), , printed values first array, nothing other 2 arrays.
don't mean
$(document).ready(function() { var event = <?php echo json_encode($array) ?>; $.each(event, function( index, value ){ console.log(value); // use 'value' not 'event'. }); });
Comments
Post a Comment