Guest User

ajax login

a guest
Jul 31st, 2016
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function login() {
  2.          var user  = $('#uName').prop('value');
  3.          var password = $('#uPassword').prop('value');
  4.          user = user.trim();
  5.          password = password.trim();
  6.          
  7.         if(user == ""){
  8.             $("#message").html("Enter a User Name");
  9.             $('#uName').focus();
  10.             return false;
  11.          }
  12.         if(password == ""){
  13.            $("#message").html("Enter the Password");
  14.            $('#uPassword').focus();
  15.             return false;
  16.          }
  17.                
  18.         $.ajax({
  19.                 url: "login",
  20.                 type: "POST",
  21.                 dataType: "json",                  
  22.                 data: {username: user,password:password},                      
  23.                 async: false,
  24.                 cache: false,                        
  25.                 success: function(response){ if(response["status"] == "success") {
  26.                       $("#message").html(response["message"]);
  27.                       showMsg();
  28.                       $("#hidStatus").prop("value","update");                      
  29.                   } else if(response["status"] == "failure") {
  30.                        $("#message").html(response["message"]);
  31.                        showMsg();                      
  32.                    }
  33.                },
  34.                 error: function(err){
  35.                    alert("Error in Login...");                        
  36.                }
  37.            });                
  38.        
  39.        }
Add Comment
Please, Sign In to add comment