ashx+jquery+ajax 不多数 上代码

来源:互联网 发布:苹果 mac 百度云 商店 编辑:程序博客网 时间:2024/05/16 01:05
写一个Handler
namespace WebTest.handle{    /// <summary>    /// myHandler1 的摘要说明    /// </summary>    public class myHandler1 : IHttpHandler    {        public void ProcessRequest(HttpContext context)        {            context.Response.ContentType = "text/plain";            string name = context.Request["tname"];            context.Response.Write("Hello World!"+name);        }        public bool IsReusable        {            get            {                return false;            }        }    }}
前台调用js
<script type="text/javascript">        function text_ajax() {            var tt = $("#text1").val();            alert(tt);            $.post("handle/myHandler1.ashx", {tname:tt} ,            function (data) {                alert(data)            });                    }        </script>




0 0
原创粉丝点击