手写ajax,做一个笔记,代码也是从W3CCopy的

var xmlhttp;

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
 xmlhttp=new ActiveXObject(Microsoft.XMLHTTP)
}
xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { //readyState status //0: 请求未初始化 200: "OK" //1: 服务器连接已建立 404: 未找到页面 //2: 请求已接收 //3: 请求处理中 //4: 请求已完成,且响应已就绪 document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","请求的地址+参数",true); //true(异步)或 false(同步) xmlhttp.send(); //string:仅用于 POST 请求