Get XML document content asynchronously with ASP.net ajax

Source: Internet
Author: User
Tags net
ajax|asp.net|xml| Asynchronous

Ajax is intended to be used to get XML content asynchronously to achieve a web-without-refresh effect
asp.net Ajax has encapsulated the underlying content
The implementation is far more convenient than writing XMLHTTP, at least the browser compatibility is much stronger
Here's a www.asp.net example of how to use a Microsoft Ajax library to get an XML document simple and asynchronous

//return XML Web request
Function onsucceededxml (executor, EventArgs)
... {
    if (executor.get_responseavailable ())
    ... {
      
        if (document.all)
            Resultelementid.innertext + = Executor.get_xml ( ). xml;
        Else
            //Firefox
            Resultelementid.textcontent + = "First node[node]:" +
                 executor.get_xml (). Documentelement.nodename;

   }
    else
    ... {
        if (executor.get_timedout ())
             alert ("timeout");
        Else
             if (executor.get_aborted ())
                 alert ("failure");
   }
}
Function GetXml ()
... {
   //Create WebRequest object
    wrequest =  new Sys.Net.WebRequest ();

Set up request files
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 ();
}
>Xml




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.