XmlHttpRequest是AJAX的基础
每个类型浏览器XmlHttpRequest对象的实现方式不一样
以下函数用于创建XmlHttpRequest对象
function CreateXmlHttp(){
var ARR_ACTIVEX = ["MSXML4.DOMDocument",
"MSXML3.DOMDocument",
"MSXML2.DOMDocument",
"MSXML.DOMDocument",
"Microsoft.XmlDom"];
var STR_ACTIVEX = "",xmlHttp=false;;
var bXMLCtlFound = false;
for(var i=0; i < ARR_ACTIVEX.length && !bXMLCtlFound; i++){
try{
xmlHttp = new ActiveXObject(ARR_ACTIVEX[i]);
STR_ACTIVEX = ARR_ACTIVEX[i];
bXMLCtlFound = true;
}
catch(e){
xmlHttp=null
}
}
if (!bXMLCtlFound){
try{
xmlHttp=new XmlHttpRequest();
}
catch(e){
throw "No DOM Document found on your computer.";
}
}
return xmlHttp;
}
function CreateXmlHttp(){
var ARR_ACTIVEX = ["MSXML4.DOMDocument",
"MSXML3.DOMDocument",
"MSXML2.DOMDocument",
"MSXML.DOMDocument",
"Microsoft.XmlDom"];
var STR_ACTIVEX = "",xmlHttp=false;;
var bXMLCtlFound = false;
for(var i=0; i < ARR_ACTIVEX.length && !bXMLCtlFound; i++){
try{
xmlHttp = new ActiveXObject(ARR_ACTIVEX[i]);
STR_ACTIVEX = ARR_ACTIVEX[i];
bXMLCtlFound = true;
}
catch(e){
xmlHttp=null
}
}
if (!bXMLCtlFound){
try{
xmlHttp=new XmlHttpRequest();
}
catch(e){
throw "No DOM Document found on your computer.";
}
}
return xmlHttp;
}