Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- $(".authentication").hide();
- $(".message").hide();
- $.ajax({
- url: "chat.php",
- cache: false,
- type: "POST",
- data: { get: true },
- success: function(data) {
- $(".messages").html(data);
- }
- });
- $("#login").click(function() {
- $.ajax({
- url: "authentication.php",
- cache: false,
- type: "POST",
- data: { clicked: 0, username: $(".login-username").val(), password: $(".login-password").val() },
- success: function(data) {
- if (!data.includes("try again")) {
- location.reload();
- } else {
- $(".message").html(data);
- $(".message").slideDown();
- }
- }
- });
- });
- $("#register").click(function() {
- $.ajax({
- url: "authentication.php",
- cache: false,
- type: "POST",
- data: { clicked: 1, username: $(".register-username").val(), password: $(".register-password").val(), confirmPassword: $(".confirm-password").val() },
- success: function(data) {
- if (data.includes("Success")) {
- location.reload();
- } else {
- $(".message").html(data);
- $(".message").slideDown();
- }
- }
- });
- });
- $("#send").click(function() {
- $.ajax({
- url: "chat.php",
- cache: false,
- type: "POST",
- data: { get: false, message: $("#message").val() },
- success: function(data) {
- if (data.includes("login")) {
- $(".authentication").slideDown();
- }
- $(".messages").html(data);
- }
- });
- });
- });
- $("#logout").click(function() {
- $.ajax({
- url: "authentication.php",
- cache: false,
- type: "POST",
- data: { clicked: 2 },
- success: function(data) {
- location.reload();
- }
- });
- });
- $("#authentication").click(function() {
- $(".authentication").slideToggle();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement