// 前后端数据交互都是字符串 - json
const xhr = new XMLHttpRequest()
xhr.open('get', 'http:localhost:3000/jsonData')
xhr.send()
xhr.onload = function () {
console.log(xhr.responseText)
console.log(xhr.readyState) //4
}
readystate
ajax状态码 0 1 2 3 4
xhr.onreadystatechange = function () {
console.log(xhr.readyState) //4
}
|