你所拥有的看起来是对的,现在你已经返回了JSON
你可以操作的东西,myPlayList
因为它现在是一个 JS 对象。
如果他正确地构造了文件,下面的例子作为一个变量:
var yourFriendsSongs = {
"Song":
{
name:"song name",
mp3:"songpath.mp3",
ogg:"ogg path"
}
"Song":
{
name:"song name",
mp3:"songpath.mp3",
ogg:"ogg path"
}
"Song":
{
name:"song name",
mp3:"songpath.mp3",
ogg:"ogg path"
}
"Song":
{
name:"song name",
mp3:"songpath.mp3",
ogg:"ogg path"
}
};
拨打电话:
$.getJSON(my_url_to_friendsSongList, function(data) {
myPlayList = data;
});
然后使用jQuery遍历每个
$.each(myPlaylist.Song,function(index,item){
alert(item[index].name);
alert(item[index].mp3);
alert(item[index].path);
//Whatever you want to do with the data
});