Guest User

Untitled

a guest
Feb 11th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.  
  4.  
  5. function clicked()
  6. {
  7.     console.log("Hello Wrld!");
  8.    
  9.     if(typeof XMLHttpRequest!="undefined")
  10.     {
  11.         var xmlhttp = new XMLHttpRequest;
  12.     }
  13.     else
  14.     {
  15.         console.log("Undefined");
  16.     }
  17.    
  18.     xmlhttp.onreadystatechange = function (){
  19.         //response received in this function
  20.         console.log("Got inside respone");
  21.         console.log(xmlhttp.readyState);
  22.         if(xmlhttp.readyState==4)
  23.         {
  24.             console.log("Got inside actual response");
  25.             console.log(xmlhttp.responseText);
  26.         }
  27.        
  28.        
  29.     }
  30.     console.log("Got here by json data");
  31.     var json_data = {"username" : "Joe"};
  32.     xmlhttp.open("POST","http://localhost:8080/alpha/welcome.php",true);
  33.     xmlhttp.setRequestHeader("Content-type","application/json");
  34.     //xmlhttp.setRequestHeader("content-length", json_data.length);
  35.     //xmlhttp.setRequestHeader("connection", "close");
  36.    
  37.     xmlhttp.send(json_data);
  38.    
  39.     var username = document.getElementById('username');
  40.     var password = document.getElementById('password');
  41.    
  42.     var detUser = "Unknown";
  43.     var detPassword = "Unknown";
  44.    
  45.    
  46.     if(username.value == detUser && password.value == detPassword)
  47.     {
  48.         console.log("Made it to first if");
  49.         //alert("Login Successful");
  50.     }
  51.     else if(username.value == detUser)
  52.     {   console.log("1");
  53.         //alert("Username is right at least");
  54.     }
  55.     else if(password.value == detPassword)
  56.     {
  57.         console.log("2");
  58.         //alert("Password is right at least");
  59.         console.log("Password is " + password.value);
  60.     }
  61.     else
  62.     {
  63.         //alert("Inccorrect user info, try again.");
  64.     }
  65.  
  66.  
  67. }
Add Comment
Please, Sign In to add comment