如何做阿里巴巴的网站首页,网站建设美工,写论文的好网站,百度seo如何优化Ajax
概念#xff1a;Asynchronous Javascript Anderson XML#xff0c;异步的JavaScript和XML
作用#xff1a;数据交换#xff1a;通过Ajax可以给服务器发送请求#xff0c;并获取服务器相应数据 异步交互#xff1a;可以在不重新加载整个页面的情况下#xff0c;与…Ajax
概念Asynchronous Javascript Anderson XML异步的JavaScript和XML
作用数据交换通过Ajax可以给服务器发送请求并获取服务器相应数据 异步交互可以在不重新加载整个页面的情况下与服务器交换数据并更新部分网页的技术
Axios
介绍Axios对原生的Ajax进行了封装简化书写快速开发
步骤
1.引入Axios的js文件 script srcaxios-0.18.0.js/script 2.使用Axios发送请求并获取响应结果 axios.get().then(result{ console.log(result.data); }) !DOCTYPE html
html langen
headmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleAjax-Axios/titlescript srcaxios-0.18.0.js/script
/head
bodyinput typebutton value获取数据GET onclickget()input typebutton value获取数据POST onclickpost()
/body
Scriptfunction get(){/* axios({method:get,url:}).then(result {console.log(result.data);}) */axios.get().then(result{console.log(result.data);})}function post(){/* axios({method:post,url:}).then(result {console.log(result.data);}) */axios.post().then(result{console.log(result.data);})}
/Script
/html