日期:2014-05-17 浏览次数:20543 次
<head>
<script src="../JS/jquery-1.7.2.min.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
$.ajax({
type: "POST",
url: "Demo.ashx",
dataType: "text",
async: true,
cache: false,
data: { name: 'test' },
success: function(data) {
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('当你狂刷新页面的时候就弹出来了');
}
});
</script>
</body>
</html>
<%@ WebHandler Language="C#" Class="Demo" %>
using System;
using System.Web;
public class Demo : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("1");
}
public bool IsReusable
{
get
{
return false;
}
}
}
data: { "val1": v1, "val2": v2 }, //注意!!!ASHX和WebService传data格式不同!!这是WS的 data: "{val1:'" + v1 + "',val2:'" + v2 + "'}",
POST 修改成&nbs