- jQuery實現ajax封裝,ajax技術實現了網頁的局部數據刷新
- axios是通過promise實現對ajax技術的一種封裝
- axios是ajax ajax不止是axios
axios({
url: '/getUsers',
method: 'get',
responseType: 'json',
data: {}
}).then(function (response) {
console.log(response);
console.log(response.data);
}).catch(function (error) {
console.log(error);
})
1. 從 node.js 創建 http 請求
2. 支持 Promise API
3. 客戶端支持防止CSRF
4. 提供了一些併發請求的接口
$.ajax({
url: '/getUsers',
type: 'get',
dataType: 'json',
data: {
},
success: function (response) {
console.log(response);
}
})
5. 本身是針對MVC的,不符合現在前端的MVVM
6. 基於原生的XHR開發,本身使用起來不方便,有了替代的fetch
7. 只爲了使用ajax引入jQ得不償失