asp.net Ajax基础操作
小弟才学习Ajax技术,因为是自学的。现在遇到问题,想请教大神,前辈。。
做了一个测试:
asp代码:
<script type="text/javascript" src="jQuery/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#loginBtn").click(function () {
alert($("#userName").val());
$.ajax({
type: "post",
url: "TestAbc.ashx",
data: { userName: $("#userName").val(), userPwd: $("#userPwd").val() },
success: function (responseText) {
if (responseText == "1") {
window.location.href = "success.aspx";
} else if (responseText == "0") {
alert("登录失败...");
}
}
});
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="userName" runat="server"></asp:TextBox>
<asp:TextBox ID="userPwd" runat="server"></asp:TextBox>
<asp:Button ID="loginBtn" runat="server" Text="登 录"></asp:Button>
</div>
ashx 代码:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
Login ll = new Login();
str