JQuery Ajax and Getjson get background normal JSON data and hierarchical JSON data usage analysis _jquery

Source: Internet
Author: User
Tags eval

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.

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.