ASP.NET – ASHX + jQuery POST 使用方法
WebForm1.aspx |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function () { $("#btn1").click(function(){ $.post("Handler1.ashx", {}, function(data){ $("#result").html(data); }); }); }); </script> <form id="form1" runat="server"> <div> <input type="button" id="btn1" value="ashx Submit" /><br /> <span id="result"></span> </div> </form> |
Handler1.ashx |
using System; using System.Web; namespace WebApplication1 { public class Handler1 : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("ashx Return"); } public bool IsReusable { get { return false; } } } } |