1. <div id="app"></div>
    2. <h2>列表数据</h2>
    3. <p class="dp"></p>
    4. <audio src="" controls></audio>
    5. <script>
    6. /* 回调地狱 */
    7. /* 1.华语中的第一条数据 */
    8. var url ='http://192.168.4.18:3000/top/playlist/?cat=华语';
    9. $.ajax({
    10. url,
    11. success:res=>{
    12. var {name,id} = res.playlists[0]
    13. $("#app").html(name)
    14. /* 2.列表页的数据 */
    15. var listUrl = `http://192.168.4.18:3000/playlist/detail?id=${id}`;
    16. $.ajax({
    17. url:listUrl,
    18. success:res=>{
    19. var {name,id} = res.playlist.tracks[0]
    20. $(".dp").html(name)
    21. console.log(id)
    22. /* 3.根据id获取音乐播放的url链接 */
    23. var musicUrl = `http://192.168.4.18:3000/song/url?id=${id}`
    24. $.ajax({
    25. url:musicUrl,
    26. success:res=>{
    27. let src = res.data[0].url;
    28. $("audio").attr("src",src)
    29. }
    30. })
    31. }
    32. })
    33. }
    34. })
    35. </script>