ajax
<%@pagelanguage="java"contentType="text/html;charset=utf-8"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<%@includefile="baseReference.jsp"%>
<%@taglibprefix="spring"uri="../tld/spring.tld"%>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">
<title>Login</title>
</head>
<body>
<formname="form"action="${basePath}/user/userInformation.action"method="post">
用户名:<inputtype="text"id="username"name="username"/>
密 码:<inputtype="password"id="password"name="password"/>
验证码:<inputtype="text"id="checkcode"name="checkcode"/><imgid="code"src="${basePath}/user/createCode.action"><ahref="#"onclick="changeCode()">看不清,换一张</a>
<inputtype="button"name="sm"value="登录"onclick="checkRegisted()">
<ahref="${basePath}/user/register.action">注 册</a>
</form>
</body>
<scripttype="text/javascript">
functioncheckRegisted(){
varusername=$("#username").val();
varpassword=$("#password").val();
if(null==username||null==password){
alert("用户名或密码不能为空!");
return;
}
varurl="${basePath}/user/checkRegisted.action";
$.post(url,{username:username,password:password},function(result){
if("false"==result){
alert("用户名或密码错误!或者权限异常!");
}else{
alert("欢迎登陆!");
document.form.submit();
}
});
varurl="${basePath}/user/checkCode.action";
$.post(url,{checkcode:checkcode},function(result){
if("true"==result){
alert("ok!");
return;
}else{
alert("RE");
}
});
}
functiongetXMLRequest(){
varrequest;
try{
request=newXMLHttpRequest();
}catch(e){
try{
request=newActiveXObject("Microsoft.XMLHttp");
}catch(e){
alert("AJAX!!!");
returnnull;
}
}
returnrequest;
}
//改变验证码
functionchangeCode(){
varrequest=getXMLRequest();//XMLHttpRequest
request.onreadystatechange=function(){
if(request.readyState==4){
document.getElementById("code").src="${basePath}/user/createCode.action?"+newDate();
}
};
request.open("GET","${basePath}/user/createCode.action",true);
request.send(null);
}
</script>
</html>
相关推荐
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo