function DefineRequest() {//初始化、指定处理函数、发送请求的函数
//开始初始化XMLHttpRequest对象
var xmlRequest;
try{
if(window.ActiveXObject)
{
var MSXML = new Array('MSXML2.XMLHTTP','Microsoft.XMLHTTP','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.5.0');
for(var i=0;i<MSXML.length;i++)
{
try
{
xmlRequest = new ActiveXObject(MSXML[i]);
break;
}
catch(e)
{
xmlRequest = null;
}
}
}
else if(window.XMLHttpRequest)
{
xmlRequest = new XMLHttpRequest();
if(xmlRequest.overrideMimeType)
{
xmlRequest.overrideMimeType('text/xml');
}
}
if(xmlRequest == null)
{ // 异常,创建对象实例失败
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
}
catch(e){}
return xmlRequest;
}
//定义xmlhttp对象
var xmlhttp = new DefineRequest();