0

I have this problem, when the user is validated I ask the server for the following page but it does not show it. I do not have experience. Thank you.

let base_url = window.location.origin;
function Login() {
    let url = base_url + "/login";
    let username = document.getElementById("username").value;
    let password = document.getElementById("password").value;
    let xhr = new XMLHttpRequest();
    xhr.open("GET", url + "?username="+ username + "&password=" + password, false);
    xhr.send();

    if (xhr.status == 200) {  
        xhr.open("GET", base_url + "/getacdreport", false);
        xhr.send();
        //console.log(xhr.responseText); 
    } else {
        alert(xhr.responseText);
    }
}

Jorge
  • 13
  • 4
  • 2
    Does this answer your question? [How do I redirect to another webpage?](https://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-webpage) – Alon Eitan Sep 14 '20 at 12:27

1 Answers1

0

Are you looking for this ? I mean, inside your if block, redirecting to another URL ?

if (xhr.status == 200) {  
    window.location.href = window.location.origin + "/getacdreport";
    //console.log(xhr.responseText); 
} else {
    alert("Invalid username/password");
}
Sowjanya R Bhat
  • 1,128
  • 10
  • 19