This article is an example of jquery Ajax and Getjson fetching background normal JSON data and hierarchical JSON data usage. Share to everyone for your reference, specific as follows:
The screenshot of the running effect is as follows:
The specific code is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<%@ WebHandler language= "C #" class= "Jsondata"%> using System;
Using System.Web;
Using System.Web.Script.Serialization;
Using System.IO;
Using System.Text;
Using System.Collections;
Using System.Collections.Generic;
Using System.Data;
Using Newtonsoft.json; public class Jsondata:ihttphandler {public void ProcessRequest (HttpContext context) {context.
Response.ContentType = "Text/plain"; Context.
Response.Cache.SetNoStore (); String type = context.
request["type"]; if (type== "1")//Normal data {list<dictionary<string, string>> AA = new list<dictionary<string, Stri
Ng>> (); for (int i = 0; i < 6; i++) {dictionary<string, string> AAA = new dictionary<string, string>
(); Aaa.
ADD ("id", "no" + i); Aaa.
ADD ("name", "John" + i); Aaa.
ADD ("Age", "21"); Aaa.
ADD ("Score", "1001"); Aa.
ADD (AAA);
String json = Jsonconvert.serializeobject (AA, formatting.indented); Context.
Response.Write (JSON);
} if (type = = "3")//Level data {list<student> List = new list<student> ();
for (int i = 0; i < 6; i++) {Student a = new Student ();
a.ID = "no" + i;
A.name = "John" + I;
A.age = "21";
dictionary<string, string> dic = new dictionary<string, string> (); Dic.
ADD ("Language", "80"); Dic.
ADD ("Mathematics", "81"); Dic.
ADD ("English", "83"); Dic.
Add ("Creature", "89"); Dic.
ADD ("Chemistry", "90"); Dic.
ADD ("Physics", "95");
A.score = dic; List.
Add (a);
String json = Jsonconvert.serializeobject (list, formatting.indented); Context.
Response.Write (JSON);
struct Student {public string id;
public string name;
public string age;
Public dictionary<string,string> score;
public bool IsReusable {get {return false;
}
}
}
More interested readers of jquery-related content can view the site's topics: A summary of Ajax usage in jquery, a summary of jquery table (table) operations tips, a summary of jquery drag-and-drop effects and techniques, a summary of jquery extension techniques, jquery Common Classic Effects Summary "jquery animation and special effects usage Summary", "jquery selector usage Summary" and "jquery common Plug-ins and Usage summary"
I hope this article will help you with the jquery program design.