ssh+jap+ajax完成登录及验证
丿假灬面彡 2015-08-13 09:07:24 $.post的action提交不上,只能提交from的action怎么办
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<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">
<title>登录</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="css/site.css" rel="stylesheet">
<link href="css/styleone.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script type="text/javascript">
$(function() {
$(":input[name=userName]").change(function(){
var val=$(this).val();
val=$.trim(val);
var $this=$(this);
if(val !=""){
//已经有的删除font
$this.nextAll("font").remove();
// alert("发送请求");
var url = "Login-exe";
var args={"userName":val()};
$.post(url,args,function(date){
//表示可用
if(data=="1"){
alert("没有该用户");
$this.after("<font color ='green'>没有该用户</font>");
}
//表示不可用
else if(data=="0"){
alert("用户名正确");
$this.after("<font color ='red'>用户名正确</font>");
}
//服务器错误
else{
alert("服务器错误");
}
});
}else{
alert("lastName 不能为空");
$(this).val("");
}
});
})
</script>
</head>
<body>
<s:form id="login-form" class="well" action="Login-login" method="post">
<table width="100%">
<tr>
<td width="22%">
<div class="ks">用户名:</div>
</td>
<td width="78%">
<s:textfield class="span2" name="userName" >
</s:textfield>
</td>
<tr>
<td></td>
<td>
<button id="loginButton" type="submit" class="btn " >
登录</button>
</td>
</tr>
</table>
</s:form>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/site.js"></script>
</body>
</html>