jquery ajax 编写登入界面
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../js/jquery-1.9.1.js"></script>
<script type="text/javascript">
function ww() {
$.ajax({
url: "test.ashx?r=" + Math.random(),
type: "GET",
data: { "acc": $("#acc").val(), "pwd": $("#pwd").val(), "code": $("#code").val() },
async: false,
success: function (msg) {
alert(msg.toString());
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<input id="acc" type="text" />
</td>
</tr>
<tr>
<td>
<input id="pwd" type="text" /></td>
</tr>
<tr>
<td>
<input id="code" type="text" /></td>
</tr>
<tr>
<td>
<input type="button" onclick="ww()" value="login" />
</tr>
</table>
</div>
</form>
</body>
</html>
test.ashx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication1
{
/// <summary>
/// test 的摘要说明
/// </summary>
public class test : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
if (context.Request.QueryString["acc"] == null)
{
HttpContext.Current.Response.Write("acc");
return;
}
if (HttpContext.Current.Request.QueryString["acc"].ToString() == "")
{
HttpContext.Current.Response.Write("acc=''");
return;
}
if (context.Request.QueryString["pwd"] == null)
{
HttpContext.Current.Response.Write("pwd");
return;
}
if (HttpContext.Current.Request.QueryString["pwd"].ToString() == "")
{
HttpContext.Current.Response.Write("pwd=''");
return;
}
if (context.Request.QueryString["code"] == null)
{
HttpContext.Current.Response.Write("code");
return;
}
if (HttpContext.Current.Request.QueryString["code"].ToString() == "")
{
HttpContext.Current.Response.Write("code=''");
return;
}
HttpContext.Current.Response.Write("yes");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
成功 嗯哈
浙公网安备 33010602011771号