我的问题可能有点令人困惑,但这是我想做的。我有一个脚本:
<script>
...some script here...
var audioPlaylist = new Playlist("2", [
{
name:"Lismore",
mp3:"http://example.com/song.mp3"
},
{
name:"The Separation",
mp3:"http://example.com/song1.mp3"
}
])
</script>
我想做的是使用 $.get.JSON 动态生成该脚本
var audioPlaylist = new Playlist("2", [
$.getJSON('http://www.example.com/users', function(data) {
$.each(data, function(i,item) {
document.write(name: ''item.fname'',)
document.write(mp3: "http://example.com/"''+item.song_id+''".mp3")
}):
});
])
在 - 的里面<script>
这可能吗?我已经尝试过脚本,但它失败了。