复制代码代码如下 :
<! 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">
<헤드>
<제목> </title>
<script type = "text/javaScript"src = "lib/jquery-1.7.2.min.js"> </script>
<script type = "text/javaScript">
$ (function () {
$ ( "#btnsubmit"). 클릭 (function () {
$ .ajax ({
유형 : "Post",
URL : "handler02.ashx",
데이터 : $ ( "#frmuserinfo"). serialize (),
성공 : 기능 (결과) {
$ ( "#msg"). html (결과);
}
});
거짓을 반환합니다.
});
});
</스크립트>
</head>
<body>
<form id = "frmuserinfo"action = "#">
<테이블>
<tr>
<td>
姓名
</td>
<td>
<입력 유형 = "text"id = "txtusername"name = "txtusername" />
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<입력 유형 = "password"id = "txtuserpwd"name = "txtuserpwd" />
</td>
</tr>
<tr>
<td colspan = "2">
<입력 유형 = "제출"id = "btnsubmit"value = "提交" />
</td>
</tr>
</테이블>
</form>
<div id = "msg"> </div>
</body>
</html>
复制代码代码如下 :
/// <요약>
/// 핸들러 ler
/// </summary>
공개 클래스 handler02 : ihttphandler
{
/// <요약>
/// 请求处理
/// </summary>
/// <param name = "context"> </param>
Public Void ProcessRequest (HTTPContext Context)
{
context.response.contentType = "Text/Plain";
// 方式 方式 2 − (对应表单序列化)
문자열 username = context.request.form [ "txtusername"]. toString ();
문자열 userpwd = context.request.form [ "txtuserpwd"]. toString ();
context.response.write (String.format ( "姓名 : {0}, {1}", username, userpwd));
context.response.end ();
}
공개 부실이 있습니다
{
얻다
{
거짓을 반환합니다.
}
}
}