好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

怎样用php+ajax实现用户登录按钮加载

本篇文章使用php+ajax技术实现登录按钮加载loading效果,一个提高用户体验,二个避免重复提交表单,ajax判断加载是否完成,本文具有一定参考价值,感兴趣的朋友可以参考一下。

1 <form onsubmit="return check_login()" style="text-align: center;margin-top:50px"> 
2<input value="登 录"   class="btn_submit" id="btn_submit" type="submit"> 
3 </form>
 1 .btn_submit { 
 2background-color: #e31436; 
 3color: #fff; 
 4cursor: pointer; 
 5display: inline-block; 
 6font-size: 18px; 
 7height: 44px; 
 8line-height: 44px; 
 9text-align: center; 
10width: 200px; 
11border-radius: 2px; 
12border:none 
13 } 
14 .disabled{opacity: 0.5;cursor:default}
 1 function check_login() { 
 2if ($("#btn_submit").hasClass("disabled"));//避免重复提交  3return false; 
 4$("#btn_submit").addClass("disabled").val("正在提交"); 
 5$.post("login.php", {id: 1}, function(data) { 
 6    $("#btn_submit").removeClass("disabled").val("登 录"); 
 7    location.href = "http://HdhCmsTestsucaihuo测试数据/php/2747.html"; 
 8}, "json"); 
 9return false; 
10 }

相关教程:PHP视频教程

以上就是怎样用php+ajax实现用户登录按钮加载的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于怎样用php+ajax实现用户登录按钮加载的详细内容...

  阅读:46次