1

I tried to modify the src attribute of the tag and reload it. However, this seems not work.

     $.getJSON('/handler', function(data) {
        var items=[]
        alert('data')
        $('#artist').html(data.artist);
        $('#title').html(data.title);
        $(".audio").attr('src', data.url);
        $(".audio").attr('autoplay', true);
        $(".audio").load();
    }



        <audio id="players" class="audio" controls>
        <!-- <source src="horse.ogg" type="audio/ogg"> -->
        <source  src="http://mr4.douban.com/201307252205/c015e7928c2cbcb3be6ad0e38ff21838/view/song/small/p1451474.mp3" type="audio/mp3" reload="auto" >
            Your browser does not support the audio element.
      </audio>

I did some experiments, if change the src with some local files like:

 $(".audio").attr('src','/static/music/p186609.mp3')

This works, however if I use

 $(".audio").attr('src','http://mr4.douban.com/201307252205/c015e7928c2cbcb3be6ad0e38ff21838/view/song/small/p1451474.mp3')

This does not work.

4

1 回答 1

0

这可能是由于浏览器策略防止跨站点脚本。

于 2014-05-17T22:15:36.733 回答