Advertisement
Guest User

Untitled

a guest
Jan 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.99 KB | None | 0 0
  1. $(document).ready(function() {
  2.     $("form").submit(function(){
  3.         if ($("#username").val() == '' || $("#password").val() == '') {
  4.             alert("Sva polja moraju biti popunjena!");
  5.             event.preventDefault();
  6.         }
  7.         else {
  8.             CheckLogin();
  9.         }
  10.     });
  11. });
  12.  
  13.  
  14. function CheckLogin() {
  15.     var username = $("#username").val();
  16.     var password = $("#password").val();
  17.    
  18.     $.ajax({
  19.         url: 'login_autentification.php',
  20.         type: 'GET',
  21.         data: {'username': username, 'password': password},
  22.         dataType: 'json',
  23.         async: false,
  24.         error: function(XMLHttpRequest, textStatus, errorThrown) {
  25.             alert(textStatus +"  "+ errorThrown + "  " + XMLHttpRequest.responseText);
  26.         },
  27.         success: function (data) {
  28.             if (data=='loginFailed') {
  29.                 alert("Neispravno korisničko ime i/ili lozinka!")
  30.                 event.preventDefault();
  31.             }
  32.         }
  33.     });
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement