请帮我看看,谢谢!
var xmlHttp=createXmlHttpRequestObject();function createXmlHttpRequestObject(){
var xmlHttp;
if(window.ActiveXObject){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlHttp=false;
} }else{
try{
xmlHttp=new XMLHttpRequest();
}catch(e){
xmlHttp=false;
}
}
 
if(!xmlHttp){
alert("返回创建的对象或显示错误信息");
}else{
return xmlHttp;
}
}//点击"投票"
function addVoteNum(url,tid){
xmlHttp.open('GET',url,true);
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
alert('投票成功');
document.getElementById('tid_'+tid).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.send(null);
}
错误信息:网页错误详细信息用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
时间戳: Mon, 15 Mar 2010 02:06:31 UTC
消息: 系统错误: -1072896658。行: 34
字符: 4
代码: 0
URI: http://www.XXX.net/XXX/XXXX/ajax.js

解决方案 »

  1.   


    function createXMLHttpRequest(){
    if(window.XMLHttpRequest){ 
    XMLHttpReq = new XMLHttpRequest(); //firefox下执行此语句
    }
    else if(window.ActiveXObject){
    try{
    XMLHttpReq = new ActiveXObject("Msxm12.XMLHTTP");
    }catch(e){
    try{
    XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(e)
    {
    }
    }
    }
     }
      

  2.   

    document.getElementById('tid_'+tid).innerHTML = xmlHttp.responseText;报错指向这行,但应该没有写错吧。
    火狐3.6运行可以无刷新更新,ie7和8下不行,要刷新一下才可以看见更新结果
      

  3.   

    //点击"投票"
    function addVoteNum(url,tid){
        xmlHttp.open('GET',url,true);        
        xmlHttp.onreadystatechange = function(){
            if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
                alert(tid);
                document.getElementById('tid_'+tid).innerHTML = xmlHttp.responseText;
            }
        }
        xmlHttp.send(null);
    }
    这样试一下,可能是跑出作用域了
      

  4.   

    function createXHR(){
    // alert("xhr2");
    var xhr;
    try{
    xhr = new ActiveXObject("MsXml2.XMLHTTP");
    return xhr;
    }
    catch(e){
    try{
      xhr = new ActiveXObject("Mircosoft.XMLHTTP");
      return xhr;
    }
    catch(e){
       try{
       xhr = new XMLHttpRequest();
       return xhr;
       }
       catch(e){
       return null;
       }
    }
    }
    }
      

  5.   

    Ajax 入门简介 :

    http://www.phome.asia/forum/thread/18024.html