Guest User

Untitled

a guest
Apr 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.77 KB | None | 0 0
  1. <form action="request.php" method="POST" id="frmLogin">
  2.     <input type="text" id="edtLogin" />
  3.     <br />
  4.     <input type="password" id="edtPassword" />
  5.     <br />
  6.     <input type="submit" value="Login" id="btnLogin" />
  7. </form>
  8. <script type="text/javascript">
  9.     $(document).ready(function()
  10.     {
  11.         $("#frmLogin").submit(function(e)
  12.         {
  13.             // Sitais ir lai nesubmitojas forma, kad nospiez us pogas
  14.             e.preventDefault();
  15.            
  16.             // Sutam POST
  17.             $.post("request.php",
  18.                 {
  19.                     login       : $("edtLogin").val(),
  20.                     password    : $("edtPassword").val()
  21.                 },
  22.                 function(postBack)
  23.                 {
  24.                     // postBack = Hello from request.php!
  25.                     alert(postBack);
  26.                 }
  27.                 .error(function()
  28.                 {
  29.                     // Kaut kas nesanaca
  30.                     alert("Error...");
  31.                 })
  32.             );
  33.         });
  34.     });
  35. </script>
Add Comment
Please, Sign In to add comment