1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Document</title>
    7. <script src="lib/jquery-3.2.1.js"></script>
    8. </head>
    9. <body>
    10. <script>
    11. /*
    12. $.ajax({
    13. url, 请求的url地址
    14. type, 请求的方式
    15. data,
    16. dataType, 请求的数据类型
    17. success:res=>{ 成功的回调
    18. console.log(res)
    19. }
    20. })
    21. */
    22. /* http://192.168.4.18:3000/search?keywords=你
    23. jquery-ajax中 get传值问号后面的值,可以放在data属性中
    24. */
    25. var url = "http://192.168.4.18:3000/search?keywords=你"
    26. // $.ajax({
    27. // url,
    28. // type:"get",
    29. // data:{
    30. // keywords:"你"
    31. // },
    32. // success:res=>{
    33. // console.log(res)
    34. // }
    35. // })
    36. // $.get(url).then(res=>{
    37. // console.log(res)
    38. // })
    39. $.get(url,res=>{
    40. console.log(res)
    41. })
    42. </script>
    43. </body>
    44. </html>