ajax-Xhr

2022-12-07,

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script src="/jQuery三天学习/jquery-3.5.1/jquery-3.5.1/jquery-3.5.1.js"></script>
<script>
//1.创建 XHR 对象
var xhr = new XMLHttpRequest();
//2.调用open 函数
xhr.open("GET", "http://localhost:8080/select");

xhr.setRequestHeader(
        "Content-Type",
        "application/x-www-form-urlencoded"
         );

//3.调用send 函数
xhr.send(·参数·);

//4.监听 onreadystatechage事件
xhr.opreadystatechage = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.responseText);
}
};
</script>
</body>
</html>

ajax-Xhr的相关教程结束。

《ajax-Xhr.doc》

下载本文的Word格式文档,以方便收藏与打印。