I’m trying to write an .each statement for objects in a JSON array.
$.ajax({
url: url,
dataType: 'json',
success: function(data){
$.each(data, function (key, value){
...do stuff...
}
});
Problem is, it’s only returning one result because it’s only doing an .each for data when I need it to do an .each for the objects inside data. I’m sure it’s as simple as .each(data.something ...) but I can’t figure out what it is.
EDIT
Per comment request, data looks like:
[["data1","data2","data3"],
["data1","data2","data3"],
["data1","data2","data3"]
]
EDIT2
Here is a JSFiddle of my working code. if I change teh .each function to just do an alert it works, but when I try to build divs, it only spits out one entry.
I originally suggested using $.map() to create an array.
But the actual problem was that the OP was overwriting the html in each iteration of the loop. Editing my response to show the actual answer.
Answer: OP needed to change .html() to .append() in his .each() loop.