// 创建XMLHttpRequest对象var xhr = new XMLHttpRequest();// 设置请求方法和请求地址xhr.open('GET', 'https://api.example.com/api-endpoint');// 设置请求头xhr.setRequestHeader('Content-Type', 'application/json');// 发送请求xhr.send();// 处理请求的响应xhr.onreadystatechange = function() {// 当请求完成时if (xhr.readyState === XMLHttpRequest.DONE) {// 当请求成功时if (xhr.status === 200) {// 处理响应数据var response = JSON.parse(xhr.responseText);console.log(response);} else {// 请求失败时console.error('请求失败');}}};以上代码使用XMLHttpRequest对象发送一个GET请求到https://api.example.com/api-endpoint,并处理响应数据。请根据实际情况修改请求方法、请求地址、请求头和响应处理部分的代码。

