1. function http() {
    2. return new Promise((resolve,reject)=>{
    3. $.ajax({
    4. url:"http://192.168.4.18:3000/top/playlist/?cat=华语",
    5. type:"get",
    6. success:res=>{
    7. resolve(res)
    8. },
    9. error:err=>{
    10. reject(err)
    11. }
    12. })
    13. })
    14. }
    15. <script>
    16. http("top/playlist/?cat=华语").then(res=>{
    17. let id = res.playlists[0].id
    18. console.log(id)
    19. })
    20. </script>