ajax请求的五个步骤
1.创建XMLHttpRequest异步对象
var xhr = new XMLHttpRequest()
2.设置回调函数
xhr.onreadystatechange = callback
3.使用open方法与服务器建立连接
// get 方式
xhr.open(“get”, “test.php”, true)
// post 方式发送数据 需要设置请求头
xhr.open(“post”, “test.php”, true)
xhr.setRequestHeader(“Content-Type”, “
原创
2022-04-07 20:08:50 ·
6846 阅读 ·
0 评论