Axios:对原生的AJAX进行封装,简化书写
官网:https://www.axios-http.cn
使用:①引入axios的js文件
<script src="js/ .js"></script>
②使用axios发送请求,并获取响应结果
axios({
method:"get",
url:"http://localhost:8888/axiosServlet?username=zs"
}).then(function (resp){
alert(resp.data);
})
Axios请求方式别名(为方便起见,Axios为所有支持的请求方式提供了别名)
axios.get(url[,config]) axios.delete(url[,config]) axios.head(url[,config]) axios.options(url[,config])
axios.post(url[,data[,config]]) axios.put(url[,data[,config]]) axios.patch(url[,data[,config]])
axios.get("http://localhost:8888/axiosServlet?username=zs").then(function (resp){
alert(resp.data);
})
网友评论