<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AJAX GET 请求</title>
<style>
#result{
width: 200px;
height: 100px;
border: solid 1px #90b;
}
</style>
</head>
<body>
<button>点击发送请求</button>
<div id="result"></div>
<script>
// 获取button元素
const btn = document.getElementsByTagName('button')[0];
const result = document.getElementById('result');
// 绑定时间
btn.onclick = function (){
// 1、创建对象
const xhr = new XMLHttpRequest();
// 2、初始化 设置请求方法和 url
xhr.open('GET', 'http://127.0.0.1:8000/server?a=100&b=200&c=300');
// 3、发送
xhr.send();
// 4、事件绑定 处理服务端返回的
AJAX--GET请求
最新推荐文章于 2023-05-05 09:25:58 发布
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>AJAX GET 请求</title> <style> #result{ width: 200px; height: 100px; border: solid 1px #90.
摘要由CSDN通过智能技术生成