Guest User

Untitled

a guest
Dec 6th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. var loggedIn = 0;
  2. var auth;
  3.  
  4. $(document).ready(function(){
  5.  
  6. $('#submitLogin').click(function(){
  7.  
  8. event.preventDefault();
  9. var data ={};
  10. //$("#loginForm").serializeArray().map(function(x){data[x.name] = x.value;});
  11. console.log($("#loginForm").serializeArray());
  12. $("#loginResult").empty();
  13.  
  14. console.log("<--- PERFORMING AJAX --->");
  15. $.ajax(
  16. {
  17. type: "POST",
  18. crossDomain: true,
  19. url: 'http://localhost:3000/user/login',
  20. xhrFields: {
  21. withCredentials: true
  22. },
  23. contentType: "form-data",
  24. data: $("#loginForm").serializeArray(),
  25. success: function( responseData, textStatus, jqXHR )
  26. {
  27. auth = {username:data.inputusername, password:data.inputpassword};
  28.  
  29. $("#loginResult").html("<p style='color:green;'>login success.</p>");
  30. loggedIn = 1;
  31.  
  32. },
  33. error: function(jqXHR, textStatus, errorThrown)
  34. {
  35. $("#loginResult").html("<p style='color:red;'>An error has occurred, " + errorThrown + ".</p>");
  36. }
  37. });
  38. console.log("FINISHED?");
  39. return false;
  40. });
Add Comment
Please, Sign In to add comment