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
Web request to return XML
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 ("Failed");
}
}
function GetXml ()
... {
Creating WebRequest objects
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 ();
}
<button id= "Button3"
Onclick= "GetXml ()" >Xml</button>
<div id= "ResultId" style= "Background-color:aqua;" ></div>