Html页面1
纯Jquery表单和后台交互
Handler01
using System.Web;namespace Test{ ////// Handler 的摘要说明 /// public class Handler01 : IHttpHandler { ////// 请求处理 /// /// public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; // 方式1 string userName = context.Request.Params["txtUserName"].ToString(); string userPwd = context.Request.Params["txtUserPwd"].ToString(); context.Response.Write(string.Format("姓名:{0},密码:{1}",userName, userPwd)); context.Response.End(); } public bool IsReusable { get { return false; } } }}
Html页面2
纯Jquery表单和后台交互
Handler02
using System.Web;namespace Test{ ////// Handler 的摘要说明 /// public class Handler02 : IHttpHandler { ////// 请求处理 /// /// public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; // 方式2(对应表单序列化) string userName = context.Request.Form["txtUserName"].ToString(); string userPwd = context.Request.Form["txtUserPwd"].ToString(); context.Response.Write(string.Format("姓名:{0},密码:{1}", userName, userPwd)); context.Response.End(); } public bool IsReusable { get { return false; } } }}