renatoknot

Untitled

May 13th, 2020
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.75 KB | None | 0 0
  1. $('form[name= "login"]').submit(function(event) {
  2.         event.preventDefault();
  3.  
  4.         const form = $(this);
  5.         const action = form.attr("action");
  6.         const email = form.find('input[name = "email"]').val();
  7.         const password = form.find('input[name = "password_check"]').val();
  8.  
  9.         $.post(
  10.             action,
  11.             { email: email, password: password },
  12.             function(response) {
  13.                 console.log(response);
  14.  
  15.                 if (response.message) {
  16.                     ajaxMessage(response.message, 3);
  17.                 }
  18.  
  19.                 if (response.redirect) {
  20.                     window.location.href = response.redirect;
  21.                 }
  22.             },
  23.             "json"
  24.         );
  25.     });
Add Comment
Please, Sign In to add comment