原生的ajax

var xhr=null;

if(window.XMLHttpRequest){

  xhr=new XmlHttpRequest();

}else{

  xhr=new ActiveXObject("Mcosoft.XMLHttp")

}

xhr.onreadystatechange=function(){

  if(xhr.readyState==4 && xhr.satus==200){

    //得到字符串格式

    var str=xhr.responseText

    // 得到XML格式 var xml=xhr.responseXML;

    console.log(”执行dom操作“);

  }

}

xhr.open("get/post","xx.php",true/false);

//xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded")

xhr.send("null/data");

 

posted on 2015-11-18 11:40  装逼被人打  阅读(102)  评论(0)    收藏  举报

导航