Advertisement
Guest User

Untitled

a guest
May 17th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function () {
  2.     "use strict";
  3.     $("#submit").click(function (e) {
  4.     e.preventDefault();
  5.  
  6.         var username = $("#login").val(), password = $("#password").val();
  7.  
  8.         if ((username === "") || (password === "")) {
  9.             $("#message").html("<div class=\"alert alert-danger alert-dismissable\"></button>WprowadĹş nazwę uĹźytkownika i hasło!</div>");
  10.         } else {
  11.             $.ajax({
  12.                 type: "POST",
  13.                 url: "login-form.php",
  14.                 data: "login=" + login + "&password=" + password,
  15.                 dataType: 'JSON',
  16.                 success: function (html) {
  17.                     //console.log(html.response + ' ' + html.username);
  18.                     if (html.response === 'true') {
  19.                         //location.assign("../index.php");
  20.                         location.reload();
  21.                         return html.username;
  22.                     } else {
  23.                         $("#message").html(html.response);
  24.                     }
  25.                 },
  26.                 error: function (textStatus, errorThrown) {
  27.                     console.log(textStatus);
  28.                     console.log(errorThrown);
  29.                 },
  30.                 beforeSend: function () {
  31.                     $("#message").html("<p class='text-center'><img src='img/ajax-loader.gif'></p>");
  32.                 }
  33.             });
  34.         }
  35.         return false;
  36.     });
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement