1. <body>
    2. <div id="loading">
    3. <img src="images/loading.gif" alt="">
    4. </div>
    5. 加载成功
    6. <script>
    7. var url = "https://www.easy-mock.com/mock/5d67436424fd60626abfe912/ajax/base"
    8. /*
    9. ajax
    10. 1.请求的地址
    11. 2.请求的方式 get,post
    12. 3.请求的数据类型
    13. */
    14. $.ajax({
    15. url: url,
    16. type: "get",
    17. dataType: "json",
    18. success: function (res) {
    19. console.log(res)
    20. $("#loading").hide()
    21. },
    22. error: function (err) {
    23. console.log(err)
    24. },
    25. beforeSend: function () {
    26. $("#loading").show() //加载的页面
    27. }
    28. })
    29. </script>
    30. </body>