日期:2014-05-20  浏览次数:20379 次

ajax问题 浏览器问题
有的机子左下角会提示错误,大部分不会,估计是IE问题,帮忙看看下面的还有漏的吗?
function   getAjax()
{
var   XmlHttp;

//Creating   object   of   XMLHTTP   in   IE
try
{
XmlHttp   =   new   ActiveXObject( "Msxml4.XMLHTTP ");
}
catch(e)
{
try
{
XmlHttp   =   new   ActiveXObject( "Msxml3.XMLHTTP ");
}
catch(e)
{
try
{
XmlHttp   =   new   ActiveXObject( "Msxml2.XMLHTTP ");
}
catch(e)
{
try
{
XmlHttp   =   new   ActiveXObject( "Microsoft.XMLHTTP ");
}  
catch(oc)
{
XmlHttp   =   null;
}
}
}
}
//Creating   object   of   XMLHTTP   in   Mozilla   and   Safari  
if(!XmlHttp   &&   typeof   XMLHttpRequest   !=   "undefined ")  
{
XmlHttp   =   new   XMLHttpRequest();
if(XmlHttp.overrideMimeType)
{  
          XmlHttp.overrideMimeType( "text/xml ");  
        }  
}
return   XmlHttp;
}

------解决方案--------------------
提示什么错误,是脚本错误吗?
如果是的话,可能有的机子上没有注册msxml4.0,

------解决方案--------------------
function getAjax()
{
var XmlHttp;
try
{
XmlHttp = new ActiveXObject( "Msxml2.XMLHTTP ");
}
catch(e)
{
try
{
XmlHttp = new ActiveXObject( "Microsoft.XMLHTTP ");
}
catch(oc)
{
XmlHttp = null;
}
}
if(!XmlHttp && typeof XMLHttpRequest != "undefined ")
{
XmlHttp = new XMLHttpRequest();
}
return XmlHttp;
}

//我是这么写的从来没有出现过错误
------解决方案--------------------
可能有的机子上没有注册msxml4.0
-------------------
Msxml2.XMLHTTP都不要试试