XmlHttp 异步传输

.aspx

<Html>
<head>
   <title></title>
   <script type="text/javascript">
      var Div,xmlhttp;
      function getXmlHttp()
       {
           Div= document.getElementById("div1");
           Div.innerHTML = "正在装载栏目数据,请稍侯.......  ";
           Div.style.display = ""; 
           var strParm="*";
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
           xmlhttp.onreadystatechange = getAjaxValue;  
           xmlhttp.open("POST","Execute.aspx?type=1",true);   
           xmlhttp.send(strParm); 
       }
      function getAjaxValue()
      {
         if(xmlhttp.readystate ==4)
         {
            if(xmlhttp.status == 200)
               Div.innerHTML= xmlhttp.responseText;
            else
               Div.innerHTML = "加载失败,原因:"+xmlhttp.statusText
         }
      }
   </script>
</head>
<body>
   <form id="form1" runat="server" >
        <input type="button" id="btnXmlJ" onClick="getXmlHttp();"/>
        <div id="div1"></div>
   </form>
</body>

Execute.aspx.cs

       Stream str = Request.InputStream;
        byte[] bt = new byte[str.Length];
        str.Read(bt, 0, Convert.ToInt32( str.Length));
        string parm= Encoding.UTF8.GetString(bt);
        int type = Convert.ToInt32( Request.QueryString["type"]);
         switch(type)
         {
            //实现功能.
         }
        Response.Write(返回值);
posted @ 2008-12-11 23:06  南阳·源  阅读(906)  评论(0编辑  收藏  举报