/** ajax登录,并jquery md5 加密密码 */
function loginsubmit() {
var salt=$("#username").val();
var pwd=$("#password").val();
var md5Pwd=$.md5(pwd+salt);
var validateCode=$("#validateCode").val();
var rememberMe=$("#rememberMe").val();
data="username="+ salt
+ "&password=" + md5Pwd
+ "&validateCode=" + validateCode
+ "&rememberMe=" + rememberMe;
$.ajax({
type: "POST",
url: "loginsubmit",
dataType:'html',
data: data,
contentType:"application/x-www-form-urlencoded;charset=UTF-8",
success: function(msg){
if(msg=="ok") {
location.href = "index";
}else if (msg=="errorcode"){
alert("验证码无效!");
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.readyState);
alert(textStatus);
}
});
}
以上代码中url为 loginsubmit.html 去掉".html"即可提交 ,后台代码用的@ResponseBody注解
posted on 2016-10-27 07:46
liufx 阅读(236)
评论(0) 编辑 收藏 所属分类:
调试错误记录