jingluu
$(function () {
$("#verificationCodeBtn").click(function () {
$("#verificationCodeImage").attr("src",ctx + "/verificationCode?v=" + new Date());
});

$("#loginBtn").click(function () {
$.ajax({
type : "POST", //请求方式:POST/GET
url : ctx + "/doLogin", //请求地址
dataType : "json", //服务器返回的数据类型(text/xml/json)
data : { //传给服务器的参数
username : $("#username").val(),//获取页面中的username值,传给对应的 controller层
password : $("#password").val(),//获取页面中password值传给对应的 controller层
                verificationCode : $("#verificationCode").val()//这个是验证码中的,和你没关系
},
success : function (result) { //成功回调的方法,result为返回值json数据
console.log(result);
if(result.status == 0){
window.location = "/index";
}else {
var msg = "<span style='color: red;'>" + result.message + "</span>"
$(".login-box-msg").html(msg);
}
},
error : function (error) { //失败回调方法,error也是返回值json数据
console.log(error);
}
});
});
});
这只是例子你只要看你需要的就OK了

分类:

技术点:

相关文章:

  • 2021-12-18
  • 2022-12-23
  • 2022-02-28
  • 2022-01-24
  • 2022-03-04
猜你喜欢
  • 2021-04-12
  • 2021-11-15
  • 2021-06-08
  • 2021-06-06
  • 2022-12-23
  • 2021-09-25
  • 2021-12-28
相关资源
相似解决方案