使用jquery ajax 不进ashx页面,这什么问题,急急急...

魏飞翔 魏飞翔 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
前台

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="zt_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(function() {
$("#confirm").click(function() {

$.ajax({
url: 'Handler.ashx',
dataType: 'text',
data: 'id=1',
success: function(msg) {
alert(msg);
}
});
});

});
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" value="确定" id="confirm" />
</div>
</form>
</body>
</html>


ashx页面


<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;

public class Handler : IHttpHandler {

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string x = context.Request.QueryString["id"].ToString();

context.Response.Write('x');
}

public bool IsReusable {
get {
return false;
}
}

}

就是不进这个页面也不报错- -
...全文
评论 18
收藏 已收藏
分享
返回顶部
魏飞翔
.NET社区 62,275 成员 668,968 内容