技术积累,经验交流---Design,Ajax,Web Service,Remoting,SQL,Javascript,C#,ASP.net,CSS,Winform,vs2005,VB.net,XML,PDA,Mobile,Saas

细节决定成败!

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  83 随笔 :: 2 文章 :: 65 评论 :: 9 引用

 

1创建XmlHttpRequest对象,读取,服务器端的reponse.xml文件内容

 


     
<script type="text/javascript">
          
var xmlHttp;
          
function createXMLHttpRequest()
          
{
              
if(window.ActiveXObject)
              
{
                  xmlHttp 
= new ActiveXObject("Microsoft.XMLHTTP");
              }

              
else if(window.XMLHttpRequest)
            
{
                xmlHttp 
= new XMLHttpRequest();
             }
         }

         
function startRequest()
        
{        
            createXMLHttpRequest();
             xmlHttp.onreadystatechange 
= handleStateChange;
            xmlHttp.open(
"GET","AjaxSend.aspx?ID=1",true);
             xmlHttp.send(
null);
         }

         
function handleStateChange()
         
{
             
if(xmlHttp.readyState==4)
             
{
                 
if(xmlHttp.status==200)
                 
{
                     alert(
"来自服务器的响应:"+xmlHttp.responseText);
                    
// document.getElementById ("Text1").innerText  =xmlHttp.responseText;
                 }

             }

        }

 
2 html代码

<input id="Button1" style="width: 85px" type="button" value="发送请求" onclick="startRequest();" />&nbsp;</div>
3 AjaxSend.aspx接受客户端的提交
 protected void Page_Load(object sender, EventArgs e)
    
{
        
string str = Request["ID"].ToString();
        
if (str=="1")
        
{
            Response .Write (
"你好,欢迎您的来到!");
        }


    }
posted on 2007-03-17 09:45 ruinet 阅读(148) 评论(0)  编辑 收藏 网摘



发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 677983 6dpNoxTP21k=



相关文章:

相关链接:

free web counter