小弟在此先说声谢谢呀?
  代码如下:
  var xmlHttp = false;
        try 
        {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
           try 
           {
             xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
           } 
           catch (e2) 
           {
             xmlHttp = false;
           }
        }
        if (!xmlHttp && typeof XMLHttpRequest != 'undefined') 
        {
           xmlHttp = new XMLHttpRequest();
        }
               
        function callServer() 
        {
                  
           var url = "PageName.aspx?Id=" + escape("zx");           xmlHttp.open("POST", url, true);
           xmlHttp.onreadystatechange = updatePage;
          xmlHttp.send(null);  
        }
        function updatePage() 
        {
               if (xmlHttp.readyState == 4) {
                    var response = xmlHttp.responseText;  
                    // test1.innerHTML=response;              
                    //alert(response);
                   document.getElementById('test1').innerHTML=response;
               }
        }  最后在:
  <div><span style="padding:0 2px 0 2px; font-size:10pt; font-weight:bolder;" id="test1"  div>里显示不出来?

解决方案 »

  1.   

    没看出错误,
    ps:建议这个xmlHttp = new XMLHttpRequest(); 写到最前面
      

  2.   

    if (xmlHttp.readyState == 4) { 
                        if(xmlHttp.status==200) {
    var response = xmlHttp.responseText;  
                        // test1.innerHTML=response;              
                        //alert(response); 
                      document.getElementById('test1').innerHTML=response; 
    }
                  } 
      

  3.   

       本人先说句谢谢
       可是改成你说的那样在firefox里还是没有效果?
       
      

  4.   

    ok,我说声对不起,没仔细看,
    xhr.onreadystatechange=handler;
                xhr.open('POST',url,true);
                xhr.setRequestHeader('Content-Length',args.data.length);//post提交是要加这两行,好像上面这一行可以省略,
                xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                xhr.send("Id=" + escape("zx"); );//post提交时参数要放在这里
      

  5.   

    function createXmlHttp() {
        //根据window.XMLHttpRequest对象是否存在使用不同的创建方式
        if (window.XMLHttpRequest) {
           xmlHttp = new XMLHttpRequest();                  //FireFox、Opera等浏览器支持的创建方式
        } else {
           xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");//IE浏览器支持的创建方式
        }
    }
      

  6.   

    FF支持innerHTML吗?不太确定。
      

  7.   

    如果保证代码没错的话,一般情况楞能为文件内外码不统一,或是服务器端文件没有发送文件编码请求,火狐默认编码为UTF-8,IE为GB2312。
      

  8.   

         这是我最后改的?
          代码如下:
            var xmlHttp = false;
            if (!xmlHttp && typeof XMLHttpRequest != 'undefined') 
            {
               xmlHttp = new XMLHttpRequest();
            }
            try 
            {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (e) 
            {
               try 
               {
                 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
               } 
               catch (e2) 
               {
                 xmlHttp = false;
               }
            }
            
                   
            function callServer() 
            {
                      
               var url = "PageName.aspx?Id=" + escape("zx");
               
    //           xmlHttp.open("POST", url, true);
    //           xmlHttp.onreadystatechange = updatePage;
    //          xmlHttp.send(null);  
     xmlHttp.onreadystatechange=updatePage;
                 xmlHttp.open('POST',url,true);
                // xmlHttp.setRequestHeader('Content-Length',args.data.length);//post提交是要加这两行,好像上面这一行可以省略,
                 xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                 xmlHttp.send("Id=" + escape("zx"));//post提交时参数要放在这里        }
            function updatePage() 
            {
                   if (xmlHttp.readyState == 4) {
                    if(xmlHttp.status==200) {                     var response = xmlHttp.responseText;  
                        // test1.innerHTML=response;              
                        //alert(response);
                       document.getElementById('test1').innerHTML=response;
                       }
                   }
            }   而且还把utf-8格式加了?
            在firefox好像根本取不到数据?在IE可以