日期:2014-05-16  浏览次数:20390 次

js 在 firefox下面使用 xmlhttprequest 对象调用方法open出错 错误: uncaught exception: (¹Õ XMLHttpRequest.open ö
js   在   firefox下面使用   xmlhttprequest   对象调用方法open出错   错误:   uncaught   exception:   (¹Õ   XMLHttpRequest.open   öCP

代码
if(window.XMLHttpRequest)
{

var   reqe   =   new   XMLHttpRequest();
//alert(reqe);
reqe.open( "POST ", "http://blog.mpdaogou.com/WebService.asmx/ReturnDiscussSplit ",false);
//alert( "open ");
reqe.setRequestHeader( "Content-Type ", "application/x-www-form-urlencoded ");
reqe.send( "topicid= "+1+ "&no= "+1);
alert(reqe.responseText);

}

------解决方案--------------------
在var reqe = new XMLHttpRequest(); 之前最好选判断一下你的浏览器是什么
function GetXmlHttp()
{
if (window.XMLHttpRequest)
{
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType("text/xml");
}
}
else if (window.ActiveXObject)
{
try
{
http_request = new ActiveXObject("Mscml2.XMLHTTP");
}
catch(e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(ex)
{}
}
}
if(!http_request){
window.alert("Your broswer not support XMLHttpRequest!");
}

return http_request;
}

------解决方案--------------------
JScript code
在var   reqe   =   new   XMLHttpRequest(); 之前最好选判断一下你的浏览器是什么
function GetXmlHttp()
{
    if (window.XMLHttpRequest)
    {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
        {
            http_request.overrideMimeType("text/xml");
        }
    }
    else if (window.ActiveXObject)
    {
        try
        {
            http_request = new ActiveXObject("Mscml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(ex)
            {}
        }
    }
    if(!http_request){
        window.alert("Your broswer not support XMLHttpRequest!");
    }

    return http_request;
}