








1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <script> function login() { $("#loginForm").validate({ submitHandler: function (form) { doLogin(); } }) }
function doLogin() { $.ajax({ url: "/login/do_login", type: "POST", data: { mobile: $("#mobile").val(), password: $("#password").val() }, success: function (data) { layer.closeAll(); if (data.code == 0) { layer.msg("成功"); window.location.href = "/goods/to_list"; } else { layer.msg(data.msg); } } , error: function () { layer.closeAll(); } }) ; }
|
1 2 3 4 5 6 7
| <div class="row" style="margin-top:40px;"> <div class="col-md-6"> <button class="btn btn-primary btn-block" type="reset" onclick="reset()">重置</button> </div> <div class="col-md-6"> <button class="btn btn-primary btn-block" type="submit" onclick="login()">登录</button> </div>
|
1 2 3 4 5 6 7 8
| @RequestMapping("/do_login") @ResponseBody public Result<String> dotoLogin(HttpServletResponse response, @Valid LoginVo loginVo) { log.info("loginVO", loginVo.toString()); String token = miaoshauserService.login(response, loginVo); return ResultVoUtils.success(token); }
|


Author:
John Doe
Permalink:
http://yoursite.com/2019/03/12/前端/Ajax/
License:
Copyright (c) 2019 CC-BY-NC-4.0 LICENSE
Slogan:
Do you believe in DESTINY?