Hi so I'm trying to create a log in form by getting a username and password from the HTML and checking if the username = Name and password = UID from the server response. Then if that is true access should be true and I would like to go to the window location "start.html" but I can't get it to go there. The server works fine. Anyone has an idea of why is this happening?
Update:: If I move the window.location inside the onload function still doesn't work
function connection() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
var request = new XMLHttpRequest();
request.open("GET", "http://localhost:8080/users?uid=" + password, true);
request.onload = function () {
// Success!
data = JSON.parse(this.response);
if (data.Nombre == username && data.UID == password) {
access = true;
}
if (access == true) {
window.location = "start.html";
}
};
request.onerror = function () {
// There was a connection error of some sort
};
request.send();