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)

}

上一篇:Ajax之Jquery封装使用举例


下一篇:AJAX上传文件