写一个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>