Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- "use strict";
- $("#submit").click(function (e) {
- e.preventDefault();
- var username = $("#login").val(), password = $("#password").val();
- if ((username === "") || (password === "")) {
- $("#message").html("<div class=\"alert alert-danger alert-dismissable\"></button>WprowadĹş nazwÄ uĹźytkownika i hasĹo!</div>");
- } else {
- $.ajax({
- type: "POST",
- url: "login-form.php",
- data: "login=" + login + "&password=" + password,
- dataType: 'JSON',
- success: function (html) {
- //console.log(html.response + ' ' + html.username);
- if (html.response === 'true') {
- //location.assign("../index.php");
- location.reload();
- return html.username;
- } else {
- $("#message").html(html.response);
- }
- },
- error: function (textStatus, errorThrown) {
- console.log(textStatus);
- console.log(errorThrown);
- },
- beforeSend: function () {
- $("#message").html("<p class='text-center'><img src='img/ajax-loader.gif'></p>");
- }
- });
- }
- return false;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement