首先,建个ajax
再建个一般处理程序
DataContractJsonSerializer所在的 命名空间是这个 System.Runtime.Serialization.Json;
public class student : IHttpHandler{ public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; DBHelper manager = new DBHelper(); Liststudents = manager.getAllStudent(); DataContractJsonSerializer json = new DataContractJsonSerializer(students.GetType()); json.WriteObject(context.Response.OutputStream, students); } public bool IsReusable { get { return false; } }}
然后是效果图