JQuery Ajax dynamically Generate table table _ajax related

Source: Internet
Author: User

Objective:

This example probably features the front desk to invoke the generic handler (Handler) through jquery Ajax, get the information that the form needs to display, and then convert it back to the foreground in JSON format, and the front desk gets the data to loop through the table, preferably with the row attached to the sheet.

Goal:

A familiarity with the use of simple jquery Ajax

b Learn how to construct basic JSON-formatted data (you can also build JSON through a third-party DLL)

C familiar with the basic usage of handler

1 Simple Effect Chart

2 Front Code

<%@ Page language= "C #" autoeventwireup= "true" codefile= "DialogAjax.aspx.cs" inherits= "Jquerytest_dialogajax"% > <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

3 Handler code

<%@ WebHandler language= "C #" class= "Testhandler"%> using System;
Using System.Web;
Using System.Collections.Generic;
Using System.Text;
Using Datadal;
Using Dataenity;
  public class Testhandler:ihttphandler {HttpRequest Request;
  HttpResponse Response; The public void ProcessRequest (HttpContext context) {//does not allow the browser to cache the context.
    Response.Buffer = true; Context.
    Response.ExpiresAbsolute = DateTime.Now.AddDays (-1); Context.
    Response.AddHeader ("Pragma", "no-cache"); Context.
    Response.AddHeader ("Cache-control", ""); Context.
    Response.CacheControl = "No-cache"; Context.
    Response.ContentType = "Text/plain"; Request = context.
    Request; Response = context.
    Response; String method = Request[' method '].
    ToString (); System.Reflection.MethodInfo MethodInfo = this. GetType ().
    GetMethod (method);
  Methodinfo.invoke (this, null);
    public void GetModuleInfo () {StringBuilder sb = new StringBuilder (); String jsondata = String.
    Empty; List<module> lsmodule = Moduledal.getmodulelist (); Sb.
    Append ("{\" module\ ": ["); for (int i = 0; i < Lsmodule.count i++) {jsondata = "{\ modulenum\": "+" \ "" + lsmodule[i]. Modulenum + "\" "+", \ "modulename\": "+" \ "" + lsmodule[i]. ModuleName + "\" "+", \ "moduledes\": "+" \ "" + lsmodule[i].
      Moduledes + "\" "+"}, "; Sb.
    Append (Jsondata); if (Lsmodule.count > 0) sb = sb. Remove (sb.)
    Length-1, 1); Sb.
    Append ("]}");
  Response.Write (SB);
    public bool IsReusable {get {return false; }
  }
}

The above code is very simple, JQuery Ajax dynamically generated table table content is complete, I hope to help.

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.