Inside ajax I want to create nested order list based on the xml data I use ajax to import. Below is what it should looks like.
i.food
a) sth
b) another sth
ii. drink
a) coke
b) juice
To do this, I have the javascript below under $.ajax.
for(var k=0;k<categoryarray.length;k++){
if(categoryarray[k][0]!==""){
$('.cate ol').append("<li>"+categoryarray[k][1]+"<ol type='a' id="k???">"+"</ol>"+"</li>");
for(var l=0;l<productarray.length;l++){
if(categoryarray[k][0]==productarray[l][2]){
$('#k???').append("<li>"+productarray[l][1]+"</li>");
}
}
}
}
I think if I assign the corresponding k value to the ol tag as id, I should be able to append the corresponding products under categories based on categoryID as foreign key. Could anyone show me how to accomplish this? Many thanks!!