格式

  1. $.ajax({
  2. url, 请求的url地址
  3. type, 请求的方式
  4. data,
  5. dataType, 请求的数据类型
  6. success:res=>{ 成功的回调
  7. console.log(res)
  8. }
  9. })
  1. http://192.168.4.18:3000/search?keywords=你
  2. jquery-ajax get传值问号后面的值,可以放在data属性中

例子

  1. var url = "http://192.168.4.18:3000/search?keywords=你"
  2. $.ajax({
  3. url,
  4. type:"get",
  5. data:{
  6. keywords:"你"
  7. },
  8. success:res=>{
  9. console.log(res)
  10. }
  11. })
  12. $.get(url).then(res=>{
  13. console.log(res)
  14. })
  15. $.get(url,res=>{
  16. console.log(res)
  17. })