<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<!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=gb2312">
<title>Ajax请求测试</title>
<style type="text/css">
body form{
margin:100px;
}
body input{
width:200px;
height:14px;
margin-top:2px;
border-width:1px;
border-style: dashed;
}
body #submit{
border-style:none;
margin-left:100px;
margin-top:20px;
height:20px;
width:40px;
background: white;
}
</style>
<script type="text/javascript">
var xmlHttp;
function validate(){
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}catch(e){
// Internet Explorer
try{
alert("here");
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
alert("您的浏览器不支持AJAX!");
return false;
}
}
}
}
xmlHttp.onreadystatechange=statusdeal(){
window.alert("here");
if(xmlHttp.readyState !=0){
window.alert(xmlHttp.readyState);
}
}
xmlHttp.open("GET","test.jsp",true);
xmlHttp.send("");
</script>
</head>
<body>
<div>
<form action="test.jsp" name="form" method="get">
user:<input type='text' name='username' id='user' onblur="validate()" /><br> //错误提示是这里有错,请高手看看
pass:<input type='password' name='password' onblur="" /><br>
<input type='submit' name=tijiao value='提交' id='submit'/>
</form>
</div>
</body>
</html>
始终无法发出请求,不知道是表单错误还是代码错误.
错误提示是:找不到对象