// 请求成功时的回调函数 // console.log(xhr.response); } else { // 请求失败时的回调函数 // console.error('Request failed with status:', xhr.status); } }; xhr.onerror = function() { // 请求失败时的回调函数 // console.error('Request failed'); }; xhr.send(); }); }); });