function checkallfolder(){
var thumbnailbox = $('#thumbnailbox');
var foldertype = ["img1", "img2", "img3", "img4", "img5", "img6", "img7"];
for (var c = 0; c < foldertype.length; c++ ){
var folder = 'Img/dfolder/'+foldertype[c];
$.ajax({
type : "POST",
url: "data.php",
contentType:"application/x-www-form-urlencoded",
dataType: "json",
data: "folder="+folder,
success: function(d) {
var temp = '';
thumbnailbox.html('');
for (var obj in d){
if (d.hasOwnProperty(obj) && d[obj].hasOwnProperty('src') && d[obj].src !== ''){
var objname = d[obj].name;
temp += "<div><img name="+d[obj].name+" class='icon' src="+d[obj].src+"></div>";
console.log(d[obj].src);
}
}
thumbnailbox.html(temp);
}
});
}
}
I am making an AJAX request to check all folders inside an image directory. I use a loop with "for" to iterate through the folders, and I can see in the console log that it is going through all 7 folders and retrieving the objects. However, when I try to display them as "img" elements with "src" attribute, only the last image (folder7/img7) is showing up. I have confirmed that all the "src" values are being fetched, so I should be getting all the images. Can someone help me figure out what is wrong with my code?