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)

}

posted @ 2018-10-24 18:31  国服第一李师师  阅读(146)  评论(0编辑  收藏  举报