通過JQuery的Ajax調用一般處理程序

    時間:2024-08-24 14:01:17 AJAX 我要投稿
    • 相關推薦

    通過JQuery的Ajax調用一般處理程序

      前言:

      本示例大概功能是前臺通過JQuery的Ajax調用一般處理程序(Handler),獲取表格需要顯示的信息,然后轉換成json格式返回給前臺,前臺獲取到數據后循環構建表格的行,最好把行附加到表里。

      目標:

      a 熟悉簡單JQuery Ajax的使用

      b 了解如何構造基本的Json格式的數據(構建Json也可以通過第三方的dll)

      c 熟悉下handler的基本用法

      1 簡單效果圖

      2 前臺代碼

      <%@ page="" language="C#" autoeventwireup="true" codefile="DialogAjax.aspx.cs" inherits="JQueryTest_DialogAjax">

      3 Handler代碼

      <%@ 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; public void ProcessRequest (HttpContext context) { //不讓瀏覽器緩存 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; ListlsModule = 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; } }}

      以上代碼超簡單吧,JQuery Ajax動態生成Table表格的內容就全部完成了,希望對大家有所幫助。

    【通過JQuery的Ajax調用一般處理程序】相關文章:

    jQuery程序設計08-05

    java程序中如何調用linux命令08-27

    高級數控編程:子程序調用及編程舉例06-01

    旅游投訴的處理程序01-23

    訴訟離婚程序一般多久07-03

    一般納稅人報稅程序09-16

    java調用cmd命令01-29

    國際鐵運聯運一般程序方式08-30

    成本核算帳務處理程序及成本項目設置的處理01-05

    jquery提交按鈕的代碼07-28

    91久久大香伊蕉在人线_国产综合色产在线观看_欧美亚洲人成网站在线观看_亚洲第一无码精品立川理惠

      日本深夜福利在线观看不卡高清 | 午夜国产欧美理论在线播放 | 婷婷色五月中文在线字幕 | 亚洲精品国产综合精品99 | 亚洲精品在线第一页 | 亚洲欧美中文幕乱码在线 |