Here is my code that uses XMLHttpRequest:
function SignUp()
{
signUpConnection = new XMLHttpRequest();
signUpConnection.onreadystatechange = processRegistration;
signUpConnection.open('GET', 'index.php?registrarse=&username='+username+'&mail='+email+'&pw='+password+'&pwr='+repeatPassword, true);
signUpConnection.send();
}
function processRegistration()
{
var details = document.getElementById("labelUsername");
if(signUpConnection.readyState == 4)
{
if((signUpConnection.responseText).indexOf("account") == -1)
{
window.location = "http://localhost/index.php?created";
}
else
{
details.innerHTML = signUpConnection.responseText;
}
}
else
{
details.innerHTML = "Loading...";
}
}
The issue I am encountering is that when a successful registration occurs (when the responseText of the XMLHttpRequest does not contain the string "account"), it does not redirect me to: "index.php?created". I have tried using assign() but it did not work either.