asp.net 中 ashx的用法演示
网页代码
<mce:script type="text/javascript"><!-- $(function () { $("#name").blur(function () { var _name = $("#name").val(); $.ajax( { type: "POST", url: "test.ashx", data:"name=" + _name, success:function(data){ alert(data); } }); }); }) // --></mce:script> </head> <body> <input type="text" id="name" /> </body>
ashx 文件 c#代码
<%@ WebHandler Language="C#" Class="test" %> using System; using System.Web; public class test : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string name = context.Request["name"].ToString(); name = name + "Hello"; context.Response.Write(name); } public bool IsReusable { get { return false; } } }