Guest User

Untitled

a guest
Dec 13th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. function login() {
  2. var url = "http://...";
  3. var username = document.getElementById("username").value;
  4. var password = document.getElementById("password").value;
  5.  
  6. var xhr = new XMLHttpRequest();
  7. xhr.open("POST", url, true);
  8.  
  9. xhr.setRequestHeader("Content-Type", "application/json");
  10.  
  11. xhr.onreadystatechange = function () {
  12. if (this.readyState == 4 && this.status == 200) {
  13. alert(xhr.responseText);
  14. window.open(welcome);
  15. }
  16. };
  17.  
  18. var obj = { UserName: username , Password: password }
  19. var data = JSON.stringify(obj);
  20.  
  21. xhr.send(data);
  22. }
Add Comment
Please, Sign In to add comment