Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var loggedIn = 0;
- var auth;
- $(document).ready(function(){
- $('#submitLogin').click(function(){
- event.preventDefault();
- var data ={};
- //$("#loginForm").serializeArray().map(function(x){data[x.name] = x.value;});
- console.log($("#loginForm").serializeArray());
- $("#loginResult").empty();
- console.log("<--- PERFORMING AJAX --->");
- $.ajax(
- {
- type: "POST",
- crossDomain: true,
- url: 'http://localhost:3000/user/login',
- xhrFields: {
- withCredentials: true
- },
- contentType: "form-data",
- data: $("#loginForm").serializeArray(),
- success: function( responseData, textStatus, jqXHR )
- {
- auth = {username:data.inputusername, password:data.inputpassword};
- $("#loginResult").html("<p style='color:green;'>login success.</p>");
- loggedIn = 1;
- },
- error: function(jqXHR, textStatus, errorThrown)
- {
- $("#loginResult").html("<p style='color:red;'>An error has occurred, " + errorThrown + ".</p>");
- }
- });
- console.log("FINISHED?");
- return false;
- });
Add Comment
Please, Sign In to add comment