📄 login.jsp
字号:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<html>
<head>
<title>Ajax验证</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript">
var req = null;
function check(){
req = new ActiveXObject("Microsoft.XMLHTTP");
req.onreadystatechange = onFinsh;
req.open("GET", "UserServlet?name="+document.form1.name.value, true);
req.send();
}
function onFinsh() {
if (req.readyState == 4) {
if (req.status == 200) {
alert(req.responseText);
} else {
alert("error data:\n"+ req.statusText);
}
}
}
</script>
</head>
<body>
<form name="form1">
用户名<input type="text" name="name"/><br>
<input type="button" value="验证" onclick="check()" />
<br>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -