$. Ajax ({ 
Async: True, // default value: true (asynchronous request) 
Cache: True, // The default value is true. setting this parameter to false will not load request information from the browser cache. 
Type: "Post", // default: GET Request Method: [post/get] 
Datatype: "XML", // default ["XML"/"html"] return data type: ["XML"/"html"/"script"/"JSON"/"jsonp"] 
URL: "test. ashx", // The default current address, the address that sends the request 
Data: {key: "value"}, // data sent to the server 
Error: function (XML) {alert ('error loading XML document' + XML) ;}, // called when the request fails 
Timeout: 1000, // set the request timeout 
Success: function (XML) {// callback function parameter after the request is successful: data returned by the server, data format. 
$ ("# Users"). Empty (); 
// Use jquery to process XML data 
$ (XML). Find ('table'). Each (function (){ 
VaR loginname = $ (this). Find ("loginname"). Text (); 
VaR name = $ (this). Find ("name"). Text (); 
$ ("# Users"). append ("<li>" + loginname + "-" + name + "</LI> "); 
}); 
/* 
$ (XML). Find ('user'). Each (function (I ){ 
VaR loginname = $ (XML). Find ("User loginname"). eq (I). Text (); 
VaR name = $ (XML). Find ("User Name"). eq (I). Text (); 
$ ("# Users "). append ("<p>" + loginname + "</P>" + "<p>" + name + "</P> <br/> "); 
}) 
 
 
 
 $ (XML ). find ("student "). each (function (I) {
 var id = $ (this ). children ("ID"); // get the object 
 var id_value = $ (this ). children ("ID "). text (); // obtain the text 
 alert (id_value); // here is the ID value. 
 alert ($ (this). ATTR ("email"); // The email attributes under student are displayed. 
 
// The final output is shown. This is the CSS rain method, which seems to be a little more JQ than macnie.
$ ('<Li> </LI> 'hangzhou.html (id_value). appendto ('ol ');
});
*/
}
})
 
 
 
Use the ashx file to return XML data:
 
 
 
<% @ Webhandler Language = "C #" class = "test" %>
 
 
Using system;
Using system. Web;
Using system. text;
Using system. Data;
 
 
 
Public class test: ihttphandler {
Public void processrequest (httpcontext context ){
Context. response. statuscode = 200;
Context. response. cache. setcacheability (httpcacheability. nocache );
 
 
 dataset DS = new dataset ("accountlist"); 
 DS = getlist ("Account", "accountid", "loginname, name", 50, 1, false, false, "1 = 1"); 
 context. response. contenttype = "text/XML"; 
 context. response. charset = "gb2312"; 
 context. response. clear (); 
 context. response. write ("  \ N "+ Ds. getxml (); 
 
/*
Stringbuilder sb = new stringbuilder ();
SB. append ("<? XML version = \ "1.0 \" encoding = \ "GBK \"?> ");
SB. append ("<accountlist> ");
SB. append ("<account> <loginname> loro5 </loginname> <Name> wulu </Name> </user> ");
SB. append ("</account> ");
Context. response. Write (sb. tostring ());
*/
 
 
 
Context. response. End ();
 
 
}
Public bool isreusable {
Get {
Return false;
}
}
 
 
 
}