<script> /* $.ajax({ url, 请求的url地址 type, 请求的方式 data, dataType, 请求的数据类型 success:res=>{ 成功的回调 console.log(res) } }) */ /* http://192.168.4.18:3000/search?keywords=你 jquery-ajax中 get传值问号后面的值,可以放在data属性中 */ var url = "http://192.168.4.18:3000/search?keywords=你" // $.ajax({ // url, // type:"get", // data:{ // keywords:"你" // }, // success:res=>{ // console.log(res) // } // }) // $.get(url).then(res=>{ // console.log(res) // }) $.get(url,res=>{ console.log(res) }) </script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> <script src="axios/http.js"></script></head><body> <script> http({ url:"/album?id=96964667" }).then(res=>{ console.log(res) }) http({ url:"/album", params:{ id:"96964667" } }).then(res=>{ console.log(res) }) </script></body>
<script> // axios是一个http的请求库 var url ="http://192.168.4.18:3000/search?keywords=你"; // axios.get(url).then(res=>{ // console.log(res) // }) axios.get("http://192.168.4.18:3000/search",{ params:{ keywords:"你" } }).then(res=>{ console.log(res) }) </script>