// 原生ajax->调用后台接口(网址、提供数据操作)
// 理解 axios 原生ajax+Promise
// 1 创建xhr对象
const xhr = new XMLHttpRequest()
// 2 配置 第一个 请求方法 第二个 请求路径 (接口文档)
xhr.open('GET', 'http://127.0.0.1:5173/list')
// 3 监听事件
// 请求过程中,状态发生变化就触发
xhr.onreadystatechange = function () {
console.log(111)
console.log(xhr.status)
}
// 4 发送
xhr.send()
ajax发送请求
最新推荐文章于 2024-07-14 16:37:30 发布