当前位置: 代码迷 >> JavaScript >> js 在 firefox下面使用 xmlhttprequest 对象调用方法open出错 异常: uncaught exception: (¹Õ XMLHttpRequest.open &ouml
  详细解决方案

js 在 firefox下面使用 xmlhttprequest 对象调用方法open出错 异常: uncaught exception: (¹Õ XMLHttpRequest.open &ouml

热度:936   发布时间:2012-02-24 16:30:39.0
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;
} 
  相关解决方案