<script>
/*
第一次尝试 ajax
*/
// 1.创建一个 ajax 对象
const xhr = new XMLHttpRequest()
// 2.配置本次的请求信息
// 请求方式:按照接口文档来进行书写
// 请求地址:按照接口文档来进行书写 http://localhost:8000/test/fist
// 是否异步: 默认是 true 表示异步请求, 选填同步请求
xhr.open( 'GET', 'http://127.0.0.1:8000/first', true)
// 3.配置请求完成后触发的事件
// 请求完整: 请求发送出去,服务器接受到了我们的请求, 并且服务器返回的信息回到了浏览器
xhr.onload = function () {
// 如何拿到后端返的信息
// 语法: xhr.resposerText
// console.log(xhr.responseText)
console.log('请求完成')
}
// 4.把本次请求发送出去
xhr.send()
</script>
报错
你这个ajax服务地址url ,不对吧 不是个http请求