安全中国首页 > 编程中心 > .NET编程
 
安全中国网友投稿专用上传FTP空间:
Ftp服务器:download.anqn.com
Ftp端口:21
用户名:anqn
密 码:anqn.com
 

利用Asp.net Ajax异步获取xml文档内容

更新时间:2008-7-29 15:10:09
责任编辑:ShellExp
热 点:

Ajax原意本是让人利用异步获取XML内容,以实现无刷新的网页效果

  asp.net ajax已将底层内容封装

  实现起来远比自写xmlhttp来的方便,至少浏览器兼容方面要强得很多

  下面以一个www.asp.net的示例说明一下利用microsoft ajax library来简单异步获取xml文档的方法

    // 返回XML的Web 请求
    function OnSucceededXml(executor, eventArgs)
    {
    if (executor.get_responseAvailable())
    {
      
        if (document.all)
            resultElementId.innerText += executor.get_xml().xml;
        else
            // Firefox
            resultElementId.textContent += "First node[首节点]: " +
                executor.get_xml().documentElement.nodeName;

    }
    else
    {
    if (executor.get_timedOut())
    alert("超时");
    else
    if (executor.get_aborted())
    alert("失败");
    }
    }
    function GetXml()
    {
    //创建WebRequest对象
    wRequest =  new Sys.Net.WebRequest();

    //设置请求文件
    wRequest.set_url("index.xml");
 
    // Set the request handler.
    wRequest.add_completed(OnSucceededXml);
   
    // Clear the results area.
    if (document.all)
    resultElementId.innerText ="";
    else
    // Firefox
    resultElementId.textContent ="";
  
    // Invoke the Web request.
    wRequest.invoke();
    }
    <button id="Button3"
    onclick="GetXml()">Xml</button>
    <div id="ResultId" style="background-color:Aqua;"></div>

 
学习软件编程开发技术,推荐加入以下软件编程培训班:
易语言软件编程培训班(简单易学)  Delphi软件编程培训班  VC++软件编程培训班
VB软件编程培训班  JAVA高端编程就业研发班

学习网站开发制作技术,推荐加入以下网站开发培训班:
ASP.net网站开发项目实战班  ASP语言网站建设培训班

学习网络安全入侵防护技术,推荐加入以下技术培训班:
大型网络安全入侵防护班  网站脚本程序全方位安全检测班

学习网络管理、网吧运营维护技术(网管),推荐加入以下培训班:
大型网吧技术管理人才特训班  Linux网络嵌入架构工程师培训班

学习专项特殊技术,推荐加入以下专项技术培训班:
软件与游戏外挂脱壳破解班(逆向工程)  赚钱王道-网赚技能培训班  Flash动画设计师就业特训班

 
相关编程
一日一文章
 
一日一软件
一日一动画