ajax核心代码:XMLHttpRequest
//定义IE所有支持的XMLHttpRequest对象版本字符串
var allVersion = ["Msxml.xmlhttp.5.0","Msxml.xmlhttp.4.0","Msxml.xmlhttp.3.0","Msxml.xmlhttp","Microsoft.xmlhttp"];
if(window.XMLHttpRequest){
var xht =new XMLHttpRequest();
}
else{
for(var i=0;i<allVersion.length;i++){
try{
var xht = new ActiveXObject(allVersion[i]);}
catch(e){
continue;
}
break;
}
try{
xht.open('get','server.html','true');
xht.onreadystatechange = function(){
if(xht.readyState ==4&&xht.status==200){
alert(xht.responseText);}
}
xht.send(null);
catch(e1){
//在IE下必须运行在服务器环境中,否则将得到拒绝访问的异常信息
alert(e1.message);
}
}
来源:https://www.cnblogs.com/xiaoyuanzi/archive/2010/02/10/1667249.html