ajax调用一般处理程序中的多个方法
js:
1 function test(){ 2 var id = $("#id").val(); 3 var pwd = $("#pwd").val(); 4 $.ajax({ 5 url: '/Tools/Handler.ashx?action=upTicketNum', 6 data:{id : id, pwd : pwd }, 7 success: function (data){ 8 alert(data); 9 } 10 }); 11 }
一般处理程序:
1 public void ProcessRequest(HttpContext context) 2 { 3 context.Response.ContentType = "text/plain"; 4 string action = context.Request["action"].ToString(); 5 switch (action) 6 { 7 case "upTicketNum": 8 upTicketNum(context); 9 break; 10 case "getTicketInfo": 11 getTicketInfo(context); 12 break; 13 case "test": 14 test(context); 15 break; 16 default: 17 break; 18 } 19 } 20 21 public void test(HttpContext context) 22 { 23 string id = context.Request["id"].ToString(); 24 string pwd = context.Request["pwd"].ToString(); 25 ///代码段 26 /// 27 HttpContext.Current.Response.Write("登录成功!"); 28 }