I have an $.each in which I have category IDs like 103 or 104 that are set with cat_id.
Now, inside that function, i want to run another $.each to access an array which has items that are sorted by those category IDs, like:
$.each( data.menu_items.items_CATID, function( key, val ) {
$.each( val, function( key2, val2 ) {
htm3+=''+val2.item_name+'..';
});
});
So basically, I need to access data.menu_items.items_103 or data.menu_items.items_104.
How do I set the variable? I tried with:
data.menu_items.items_'+cat_id+'
and such but that doesn't work.
The data is basically an array like:
menu_items:
items_251: (9) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
items_252: (6) [{…}, {…}, {…}, {…}, {…}, {…}]
data.menu_itemsin your question, so we can see what you're working on?