IQ绿色电脑总站 IQ绿色下载站 IQ电脑图片 IQ丁香鱼电脑站
网站首页 | 网络编程 | 站长学院 | 网页制作 | 图形图像 | 操作系统 | 冲浪宝典 | 软件教程 | 网络办公 | 邮件系统 | 网络安全 | 电脑故障 | 访客留言 | 内容搜索
>首页 -> 网络编程 -> Ajax教程

TOP

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

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>

[上一篇]基于css样式绑定的样式驱动式AJAX.. [下一篇]Ajax实现在textbox中输入内容,动..

评论

称  呼:
内  容:

精彩文章地带

相关栏目

最新文章

热门文章

推荐文章