$.getJSON('http://localhost/REST_API/api/post/read.php', function(data) {
var count = 0;
data.forEach(obj => {
if(count % 3 === 0) {
$( ".monsterlist" ).append("<div class='row'>");
}
$( ".monsterlist" ).append("<div class='col-sm-4'>");
$( ".monsterlist" ).append("<div class='card' style='width:400px;'>");
$( ".monsterlist" ).append("<img class='card-img-top' src='img/monster_img/"+ obj.monster_img+".png' style='width:200px;height:200px;'>");
console.log(obj.monster_img);
$( ".monsterlist" ).append("<div class='card-body'>");
$( ".monsterlist" ).append("<h4 class'card-title'>"+obj.monster_name+"</h4>");
$( ".monsterlist" ).append("<p class='card-text'>"+obj.monster_type+"</p>");
$( ".monsterlist" ).append("</div></div></div>");
count++;
});
});
Hello Everyone. I have been experimenting with my own APIs and everything seems to be working well. However, I am currently facing a challenge where I need to display the output in rows of three objects each.
I've tried different methods but haven't had any success so far. If anyone could provide some guidance on how to achieve this, I would greatly appreciate it :) Here's an example of what I've attempted so far enter link description here