How to use php+ajax to load user login button

little bottle
Release: 2023-04-06 08:22:02
forward
3040 people have browsed it

This article uses php ajax technology to achieve the loading effect of the login button. One is to improve the user experience, and the other is to avoid repeated submission of the form. Ajax determines whether the loading is completed. This article has certain reference value, and interested friends can refer to it.

Login form


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>
Copy after login

Form submission button and button invalidation style


 1 .btn_submit { 
 2     background-color: #e31436; 
 3     color: #fff; 
 4     cursor: pointer; 
 5     display: inline-block; 
 6     font-size: 18px; 
 7     height: 44px; 
 8     line-height: 44px; 
 9     text-align: center; 
10     width: 200px; 
11     border-radius: 2px; 
12     border:none 
13 } 
14 .disabled{opacity: 0.5;cursor:default}
Copy after login

Related tutorials: ajax video tutorial

Form submission verification


 1 function check_login() { 
 2     if ($("#btn_submit").hasClass("disabled"));//避免重复提交  3     return 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://www.sucaihuo.com/php/2747.html"; 
 8     }, "json"); 
 9     return false; 
10 }
Copy after login

Related tutorials: PHP video tutorial

The above is the detailed content of How to use php+ajax to load user login button. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template