在提交form表单的时候
<script type="text/javascript">
$(function(){
$("#logininfo").click(function(){
$.ajax({
type:"post",
url:"<%=basePath%>user/login.action",
dataType:"json",
data:$("#loginform").serialize(),
//contentType:"application/json",
success:function(JsonResult){
if(JsonResult.status == 200){
alert("成功!");
window.location.href="<%=basePath%>customer/customerlist.action";
}else{
alert("失败!");
}
},
error : function() {
alert("异常!");
}
})
});
});
</script>
<form id="loginform" method="post" >
<label>用户名:</label>
<br><input type="text" name="username">
<br><label>密码:</label>
<br><input type="password" name="password">
<br><button id="logininfo">登录</button>
</form>
谢谢,前端不熟悉,哈哈
$(function(){}