<!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"); //3.调用send 函数 xhr.send(); //4.监听 onreadystatechage事件 xhr.opreadystatechage = function () { if (xhr.readyState === 4 && xhr.status === 200) { console.log(xhr.responseText); } }; </script> </body> </html>
标签:调用,xhr,send,Xhr,ajax,open From: https://www.cnblogs.com/ZhuAo/p/16833221.html