ajax調用一般處理程序ashx中的多個方法

通過js調用ashx中的test()方法

js:


        function test(id,pwd){
            $.ajax({
                url: '/Tools/Handler.ashx?action=test',
                data:{id : id, pwd : pwd },
                success: function (data){
                    alert(data);
                }
            });
        }

一般處理程序(ashx):


        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = context.Request["action"].ToString();
            switch (action)
            {
                case "test":
                    test(context);
                    break;
                default:
                    break;
            }
        }

        public void test(HttpContext context)
        {
            string id = context.Request["id"].ToString();
            string pwd = context.Request["pwd"].ToString();
            ///代碼段
            ///
            HttpContext.Current.Response.Write("登錄成功!");
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章