I am new to jQuery and mixing javascript with jQuery.
Clicking add_comment_bt I send a get request to ajax.php and try to loop the data using the each statement:
(data has 2 arrays with 7 entries and it is multidimentional, you can see the data below)
c = 1;
$("#add_comment_bt").click(function () {
$.get('ajax.php', function (data) {
var arr = data;
jQuery.each(arr, function (i, val) {
var commentbox = document.createElement("div");
commentbox.id = 'commentbox' + c + '';
commentbox.className = 'comments';
container.appendChild(commentbox);
var commentBoxEach = document.getElementById('commentbox' + c + '');
var div = document.createElement("div");
div.id = 'comment' + c + '';
commentBoxEach.appendChild(div);
document.getElementById('comment' + c + '').innerHTML = "Comment: " + arr[0][i];
c++;
});
}, "json");
While looping I create two divs and put the data inside them. First 2 loops are created and work perfect but the rest of the result are not shown? Why does the loop stop?
Thanks
Here is my example JSON (I only put the first array):
[
["Green Apple", "Red Apple", "Green", "Apricot", "Banana", "Passionfruit", "Orange"],
["allen", "kate", "paul", "rose", "arnold", "ferry", "top"]
]
Here is the HTML for the container div:
<div><div id="container"></div><div id="commentDraftDiv"></div></div>
Here is the HTML result:

ias an index into the first sub-array, even though it's the loop index for the outer array.