using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Script.Serialization; using System.Runtime.Serialization.Json; using System.IO; using System.Text; namespace WebHTML5.Handler { /// <summary> /// AjaxHandlerHelper 的摘要说明 /// </summary> public class AjaxHandlerHelper : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; //context.Response.Charset = "utf-8"; var Ajax_Type = context.Request.QueryString["Ajax_Type"] == null ? context.Request.Form["Ajax_Type"] : context.Request.QueryString["Ajax_Type"]; switch (Ajax_Type) { case "Email": context.Response.Write(PostEmail(context)); break; default: context.Response.Write("[{\"Age\":28,\"Name\":\"张鹏飞\"}]"); break; } } public static string PostEmail(HttpContext context) { string semail = string.Empty; if (context.Request.HttpMethod == "GET") { semail = "[" + context.Request.QueryString["jsonData"] + "]"; } else { semail = "[" + context.Request.Form["jsonData"] + "]"; } return semail; } /// <summary> /// JSON序列化 /// </summary> public static string JsonSerializer<T>(T t) { DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T)); MemoryStream ms = new MemoryStream(); ser.WriteObject(ms, t); string jsonString = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); return jsonString; } /// <summary> /// JSON反序列化 /// </summary> public static T JsonDeserialize<T>(string jsonString) { DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)); T obj = (T)ser.ReadObject(ms); return obj; } public bool IsReusable { get { return false; } } } }
Jquery 方法扩展
关于Jquery的方法扩展大家自行google或百度;
结束语
说明一下情况:案例中出现的html5 range标签的取值问题,写的不对,大家不要在意这些,关于range标签如何取值大家自行google或百度;
您可能感兴趣的文章: