ajax原生

let xml;

let url="http://localhost:3333";

let data={name:'lishishi',age:'22'}

if(window.XMLHttpRequest){

xml=new XMLHttpRequest();

}else{

xml=new ActiveXRequest();

}

xml.open('get',url,true);//xml.open('post',url,true)

xml.send();//xml.send(JSON.stringify(data));//xml.setRequestHeader("Content-Type","application/json");

xml.onreadystatechange=function(){

if(xml.readyState==4 && xml.status==200){

console.log(xml.responseText)

}

原文地址:https://www.cnblogs.com/MDGE/p/9845335.html