下面给出的 URL 中的 JSON 数据如下所示:
{
"datum":[
{
"id":"19",
"song":"The Age of Worry",
"path":"audio/age.mp3",
"artist":"John Mayer",
"album":"Born And Raised",
"genre":"Blues-Rock",
"year":"2012",
"filename":"age",
"extension":".mp3",
"size":"6.1539077758789 MB ",
"duration":"2:40",
"downloads":"0"
}
]
}
我想提醒歌曲名称。下面的代码只提醒 id 而不是歌曲。我无法弄清楚这里出了什么问题。
switch(id){
case "1":
alert(id);
$.getJSON("http://localhost/musicstore/search.php?media=audio&search_by=song&search_string=age", function(d) {
$.each(d.datum, function (i, res) {
alert(res.song);
});
});
break;
case 2:
break;
case 3:
break;
}