//获取xmlHttp对象 function createXMLHttp() { var xmlhttp; //对于大多数浏览器适用 if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { //考虑浏览器的兼容性 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); if (!xmlhttp) { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } } return xmlhttp; }