一、获取数据
1-1、get
$.get(url,res=>{console.log(res)})$.get(url).then(res=>{console.log(res)})
$.get("http://192.168.4.18:3000/search?keywords=你").then(res=>{console.log(res)})
1-2、$.ajax
window.onload = function(){$.ajax({type:"get",url:"xx",dataType:"json",success:function(data){console.log(data);},error:function(xhr){document.body.innerHTML = xhr.status;}})
get传值问号后面的值,可以放在data属性里面
$.ajax({url,type:"get",data, // get传值问号后面的值,可以放在data属性里面dataType,success:res=>{console.log(res);}})
http://192.168.4.18:3000/search?keywords=你// get 传值 问号后面的值可以放在data属性中var url="http://192.168.4.18:3000/search";$.ajax({url,type:"get",data:{keywords:"你"},success:res=>{// console.log(res)}})
