title: JS - Making a Login page using an XMLHttpRequest
body: <p>I am attempting to create a login page on my mini site that allows users to download material. I am struggling with the xhr request, in order to check if the password and username are valid. Is the following code sufficient in what I am trying to do? Any help would be appreciated.</p>
  
  <pre><code>function login() {
  const xhr = new XMLHttpRequest();
  const uri = "localhost"; // uri for request inserted here
  xhr.open("GET", uri, true, Username, Password);
  xhr.withCredentials = true;
  xhr.onload= function() {
      const resp = JSON.parse(xhr.responseText);
      document.getElementById("Login").innerHTML = resp;
  }
  xhr.send(null)  
  }
  </code></pre>