我用xmlhttprequset使用了一下ajax,在ie下行,在firefox下不行。谁能给一个ajax的js的轻便好用的包,在.net和jsp中都能方便用。
test.aspx
  <script language=javascript>
     function   callxmlhttp()   
          {   
          var   strurl;   
          var   result;          
          strurl   =   "a.aspx?strID=100"; 
    var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
        
          xmlhttp.open("get",   strurl,   false);   
          xmlhttp.send();   
            
          result   =   xmlhttp.ResponseText;    
          document.getElementById("Text1").value=result; 
          }   
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input id="Button1" type="button" value="ajax调用" onclick="callxmlhttp()" />
        
        <textarea id="Text1" style="width: 544px; height: 418px"></textarea></div>
    </form>
</body>
</html>
a.aspx:protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Keys.Count > 0 && Request.QueryString["strID"].Length > 0)
        {
            Response.Clear();
          string  strID = Request.QueryString["strID"].ToString();
          Response.Write("要返回的值"+strID);
          Response.End();        }
    }
  以上代码在ie中没问题,在firefox中不行,不知适应多个浏览器的代码如何写,网上找了都不大对。
所以谁能提供一个好用的js包,能在.net和jsp中用就好了,免费重复学习。

解决方案 »

  1.   

    对比一下这一段吧if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = callback;
        req.open("GET", url, true);
        req.send(null);
      } // branch for IE/Windows ActiveX version
      else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
          req.onreadystatechange = callback;
          req.open("GET", url, true);
          req.send();
        }
      }
      

  2.   

    xmlhttp.open("get",   strurl,   false);   
              xmlhttp.send();   
                
              result   =   xmlhttp.ResponseText;    
              document.getElementById("Text1").value=result; --------------------------------谁教你这样写程序的?
      

  3.   

    ibm 的dojo
    google的gwt都是很好用的跨浏览器的哟