1. function http(url){
    2. return new Promise((resolve,reject)=>{
    3. $.ajax({
    4. url,
    5. success:res=>{
    6. resolve(res)
    7. },
    8. error:err=>{
    9. reject(err);
    10. }
    11. })
    12. })
    13. }
    1. <script src="lib/jquery-3.6.0.min.js"></script>
    2. <script src="promise/http.js"></script>
    3. </head>
    4. <body>
    5. <script>
    6. var url = `http://47.108.197.28:3000/top/playlist`
    7. http(url).then(res=>{
    8. console.log(res)
    9. })
    10. </script>
    11. </body>