复制代码代码如下:
<!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>
<title> </title>
<script type = "text/javascript" src = "lib/jquery-1.7.2.min.js"> </scrip>
<script type = "text/javascript">
$(function(){
$( "#btnsubmit")。クリック(function(){
$ .ajax({
タイプ:「投稿」、
URL:「Handler02.Ashx」、
データ:$( "#frmuserinfo")。serialize()、
成功:関数(結果){
$( "#msg")。html(result);
}
});
falseを返します。
});
});
</script>
</head>
<body>
<form id = "frmuserinfo" action = "#">
<表>
<tr>
<td>
姓名
</td>
<td>
<入力型= "text" id = "txtusername" name = "txtusername" />
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<input type = "password" id = "txtuserpwd" name = "txtuserpwd" />
</td>
</tr>
<tr>
<td colspan = "2">
<input type = "submit" id = "btnsubmit" value = "提交" />
</td>
</tr>
</table>
</form>
<div id = "msg"> </div>
</body>
</html>
复制代码代码如下:
/// <summary>
///ハンドラー的摘要说明
/// </summary>
パブリッククラスハンドラー02:ihttphandler
{
/// <summary>
///请求处理
/// </summary>
/// <param name = "context"> </param>
public void processRequest(httpcontextコンテキスト)
{
context.response.contenttype = "text/plain";
//方式2(对应表单序列化)
string username = context.request.form ["txtusername"]。toString();
string userpwd = context.request.form ["txtuserpwd"]。toString();
context.response.write(string.format( "姓名:{0}}、密码:{1}"、username、userpwd));
context.response.end();
}
パブリックブールIsReusable
{
得る
{
falseを返します。
}
}
}