thinkphp使用ajax实现会员登录功能
AJAX代码
<script> function ajaxPost(){ $.ajax({ type:"POST", dataType:"json", url:"{:url('Login/login')}", data:$('#myform').serialize(), success:function(data){ console.log(data); if(data.code == 200){ layer.alert(data.message,{icon:1},function(){ window.location.href = "{:url('Index/index')}"; return false; }) }else{ layer.alert(data.message,{icon:3}); return false; } }, }); } </script>
HTML部分代码
<form class="user form-horizontal" id="myform"> <div class="form-group row mb-3"> <label for="name" class="col-3 col-form-label">管理员帐号</label> <div class="col-9"> <input type="text" class="form-control" name="name" id="name" placeholder="请输入管理员帐号" required="required"> </div> </div> <div class="form-group row mb-3"> <label for="password" class="col-3 col-form-label">管理员密码</label> <div class="col-9"> <input type="password" class="form-control" name="password" id="password" placeholder="请输入管理员密码" required="required"> </div> </div> <div class="form-group row mb-3"> <label for="captcha" class="col-3 col-form-label">系统验证码</label> <div class="col-6"> <input type="text" class="form-control" id="captcha" name="captcha" placeholder="请输入右侧验证码" required="required"> </div> <div class="col-3"> <img src="{:captcha_src()}" alt="captcha" id="captcha" style="width: 100%;" onclick="this.src='{:captcha_src()}?'+Math.random();"/> </div> </div> <div class="form-group row mb-3 justify-content-end"> <div class="col-9"> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" id="checkmeout"> <label class="custom-control-label" for="checkmeout">记住密码</label> </div> </div> </div> <div class="form-group mb-0 justify-content-end row"> <div class="col-9"> <button type="button" onclick="ajaxPost()" class="btn btn-success btn-block waves-effect waves-light">登录</button> </div> </div> </form>
免责声明:
本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!
买源码 » thinkphp使用ajax实现会员登录功能
本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!
买源码 » thinkphp使用ajax实现会员登录功能