Http://www.cnblogs.com/ie421/archive/2008/08/19/1271601.html
1. JSON: newtonsoft. JSON
Http://files.cnblogs.com/ie421/Json20.zip
2. JS: jquery
3. SERVER: ashx
Public void processrequest (httpcontext context)
{
Context. response. contenttype = "text/plain ";
String method =
Context. Request. Params ["M"];
If (Method = "test ")
Context. response. Write (getpersonlistjosnstring_2 ());
}
Return Value: {"ID": 1, "firstname": "Xiao", "lastname": "yongzhi "}
4. reception on the front-end page
$ (Document). Ready (function (){
$. Getjson ("/ashx/ajax. ashx", {M: "test"}, function (JSON ){
$. Each (JSON, function (I, item ){
$ ("# Test"). append (item. ID + "." + item. firstname + "<br/> ");
})
})
});
$ (Document). Ready (function (){
$. Getjson ("/ashx/ajax. ashx", {M: "test"}, function (JSON ){
VaR TB = $ ("# tb_name_list ");
TB. Find ("TR"). Each (function (I) {// clear the table and retain the first row
If (I> 0) $ (this). Remove ();
});
$. Each (JSON, function (I, item ){
VaR
Tr = "<tr> <TD>" + item. ID + "</TD> <TD>" + item. firstname + "</TD> <TD>" + item. lastname + "</TD> </tr> ";
TB. append (TR );
})
})
});
00
«
Previous: serializing and deserializing JSON
»
Next article: Compile classes and methods in net as parameter passing. (Implemented through reflection) (that is, the implementation of passing classes and passing methods)