login.jsp

来自「ajax用户登陆验证 MyEclipse工程」· JSP 代码 · 共 41 行

JSP
41
字号
<%@ 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 + =
减小字号Ctrl + -
显示快捷键?