callback:当读取到服务器数据之后执行的函数。这个函数接受三个参数,分别是: r Ext.Record[],服务器端返回的经过reader的数组。这是官方的说法,实际测试下来似乎只有当action是read的时候才是这样,下面有介绍;options:就是arg参数的值。success:是否成功的标致,bool,这个也是服务器端返回的。
using System; using System.Web; using System.Collections.Generic;
public class dataproxy : IHttpHandler { static List db = new List(); static dataproxy() { db.Add(new Student { Id = "1", Name = "Li", Telephone = "1232" }); db.Add(new Student { Id = "2", Name = "Wang", Telephone = "5568" }); db.Add(new Student { Id = "3", Name = "Chen", Telephone = "23516" }); db.Add(new Student { Id = "4", Name = "Zhu", Telephone = "45134" }); db.Add(new Student { Id = "5", Name = "Zhou", Telephone = "3455" }); } public void ProcessRequest (HttpContext context) { string id = context.Request.Params["id"]; string action=context.Request.Params["action"]; string result = "{success:false}"; if (action == "create") { } else if (action == "read") { foreach (Student stu in db) { if (stu.Id == id) { result = "{success:true,r:[['" + stu.Id + "','" + stu.Name + "','" + stu.Telephone + "']]}"; break; } } } else if (action == "update") { } else if (action == "delete") { } context.Response.ContentType = "text/plain"; context.Response.Write(result); }
public bool IsReusable { get { return false; } }
class Student { string id; public string Id { get { return id; } set { id = value; } } string name; public string Name { get { return name; } set { name = value; } } string telephone;
public string Telephone { get { return telephone; } set { telephone = value; } } } }
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn