<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript">
function createXmlHttpRequest () {
if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}else if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
}
var xmlHttpRequest;
function checkUserName (value) {
var uname = value.value;
var url = "/sss/IndexServlet?uname=" + uname;
xmlHttpRequest = createXmlHttpRequest();
xmlHttpRequest.onreadystatechange = returnValue;
xmlHttpRequest.open("GET",url,true);
xmlHttpRequest.send(null);
}
function returnValue () {
if(xmlHttpRequest.readystate == 4 && xmlHttpRequest.status == 200) {
var value = xmlHttpRequest.responseText;
alert(value);
}
}
</script>
</head>
<body>
<form action="IndexServlet" method="get"><input type="text"
name="uname" οnblur="checkUserName (this)"><input type="submit" value="提交"></form>
</body>
</html>