ajax获取数据库中数据

时间:2023-03-08 19:53:06

xhr=new XMLHttpRequest();

var url="要获取数据的地方";

xhr.open('post',url,true);

POST请求头(get就不用写这个):xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');

字符 var str="fromname"+

xhr.send(str);

xhr.onreadystatechange=function(){

  if(xhr.readyState==4){

    if(xhr.status==200){

    }

  }

}

get的不同

url可以直接拼

xhr.send();