I have a multidimensional JSON array (see array)
{
"items" : [ {
"track" : {
"album" : {
"name" : "Pressure Makes Diamonds"
},
"artists" : [ {
"name" : "Danny Vera"
} ],
"href" : "https://api.spotify.com/v1/tracks/7rO7Pc5dkC2EIW1OKsCJtQ",
"name" : "Roller Coaster"
}
}, {
"track" : {
"album" : {
"name" : "Another Day"
},
"artists" : [ {
"name" : "Racoon"
} ],
"href" : "https://api.spotify.com/v1/tracks/64SLdE6sV5g4uQIbVIuRCq",
"name" : "Love You More"
}
}, {
"track" : {
"album" : {
"name" : "De Echte Vent"
},
"artists" : [ {
"name" : "Racoon"
} ],
"href" : "https://api.spotify.com/v1/tracks/01MCHGtGZHtYVeVUNqgMbC",
"name" : "De Echte Vent"
}
},
but I can't seem to succeed in making this a nice HTML table. I tried several things with jQuery (see code beneath), but none of them work.
var data = {!! $response !!};
var tbl=$("<table/>").attr("id","mytable");
$("#div1").append(tbl);
for(var i=0;i<data.length;i++)
{
var tr="<tr>";
var td1="<td>"+data[i]["tracks"]["album"]["name"]+"</td>";
$("#mytable").append(tr+td1);
}
It is built in Laravel8 Little help would be nice :D