Hey there! I'm currently using JSON to send a list of songs to populate my table. The JSON response is working fine up until the controller URL. However, when I attempt to loop through it and display the details in my table, I encounter an error.
$(window).load(function(){
$.get("/MusicPlayer/getSongList", function(data){
var library = data;
listSongs(library);
});
});
function listSongs(library){
var table = $("#table");
var row;
$("#table tbody").remove();
library.forEach(function(song){
row = $("<tr></tr>");
$("<td />").addClass("song-select").append($("<input
/>").attr({type:"checkbox",class:"checkbox",value:song.title})).appendTo(row);
$("<td>"+song.title+"</td>").appendTo(row);
$("<td>"+song.album+"</td>").appendTo(row);
$("<td>"+song.artist+"</td>").appendTo(row);
$("<td>"+song.rating+"</td>").appendTo(row);
$("<td>"+song.composer+"</td>").appendTo(row);
$("<td>"+song.genre+"</td>").appendTo(row);
row.click(viewFunction());
row.appendTo(table);
});
}
[
{
"title": "15 - Jacob's Theme.mp3",
"album": "The Twilight Saga - Eclipse",
"artist": "Howard Shore",
"rating": "2",
"composer": "carter ruwell",
"genre": "Soundtrack"
},
{
"title": "07_-_Vennante.mp3",
"album": "Andala Rakshasi (2012)",
"artist": "Ranjith",
"rating": "0",
"composer": "Rathan",
"genre": "TeluguMusic"
},
{
"title": "08. One Simple Idea.mp3",
"album": "Inception (OST)",
"artist": "Hans Zimmer",
"rating": "0",
"composer": "null",
"genre": "?????????"
}
]