i have an multidimensional array with objects and stuff inside it.
now its easy to loop trough the parent array and display it in html.
but my problem is lets say our array has 5 array inside of it and also each 5 arrays has 10 array inside them when i write the second loop inside the first one this happens.
now each one of 5 arrays displaying 50 arrays.
var data = [{
level_one: "outer-array-data-1",
second_level_one: {
level_two: [{"1":"1"}, {"2":"2"}, {"3":"3"}]
}
},
{
level_one: "outer-array-data-2",
second_level_one: {
level_two: [{"1":"4"}, {"2":"5"}, {"3":"6"}]
}
},
{
level_one: "outer-array-data-3",
second_level_one: {
level_two: [{"1":"7"}, {"2":"8"}, {"3":"9"}]
}
}
];
$.each(data, function(i, value) {
// display value in a html tag (parent-class)
$.each(value['second_level_one']['level_two'], function(i, elem) {
// append elem the data to (parent-class)
});
});
so i expect to get outer-array-data-1 shows inside html with 1,2,3 and so on... but i get all 1,2,3,4,5,6,7,9 for each of data.
i tried for,i++ and elem.map() but i couldn't figure this out.
(sorry about the array.thanks for any help)