原生 new XMLHttpRequest() 请求

发布时间 2023-07-04 12:03:19作者: 张二十

 

 

 

let xhr = new XMLHttpRequest();       // 先 new 一个
xhr.open("POST", "https://chunyuanqing.cn/adminapi/order/batchdelivery/import");   //请求的类型         请求的地址
xhr.setRequestHeader('Authori-zation', bz);                          //请求头header
xhr.send(fordata);                                                            //请求要上传的参数
xhr.onload = () => {
// let data = JSON.parse(xhr.response)                             //请求成功    xhr.response要转换一下
// console.log(data)
// // container.innerHTML = data.data.sys_user_agree
console.log(xhr.response);
}