Advertisement
Guest User

Untitled

a guest
Nov 7th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.   $(document).ready(function(){
  3.     $("#form_login").submit(function(){
  4.       var url = "<?php echo site_url('login') ?>";
  5.  
  6.       const Toast = Swal.mixin({
  7.         toast: true,
  8.         position: 'top-end',
  9.         showConfirmButton: false,
  10.         timer: 3000
  11.       });
  12.  
  13.       $.ajax({
  14.         url: url,
  15.         type: 'POST',
  16.         data: $('#form_login').serialize(),
  17.         dataType: "JSON",
  18.         beforeSend: function() {
  19.           $('#spinner').show();
  20.         },
  21.         success: function (data) {
  22.           console.log(data);
  23.           if (data) {
  24.             // window.location.reload(true);
  25.           } else {
  26.             Swal.fire({
  27.               type: 'error',
  28.               title: 'Oooppss!!!',
  29.               text: 'Login Failure, Check Your Credentials!'
  30.             });
  31.             $('#spinner').hide();
  32.           }
  33.         },
  34.         error: function (err, jqxhr, errthrown) {
  35.           console.log(jqxhr);
  36.         }
  37.       });
  38.       return false;
  39.     });
  40.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement