javascript:ajax的标准写法

var request;

if(window.XMLHttpRequest){

  request=new XMLHttpRequest();

}else{

  request=new ActiveXObject("Microsoft XMLHTTP");

}

request.onreadystatechange=function(){

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

    document.getElementById("ID").innerHTML=request.responseText;

  }

}

request.open("POST","https://www.baidu.com",true);//三个值:请求方式GET或者POST;请求地址;是否异步

request.send();

posted on 2017-11-27 15:21  金翅鸟  阅读(196)  评论(0编辑  收藏  举报