Please pay attention to this code.
function login(){ var xhr = new XMLHttpRequest(); xhr.open("POST", "login.php"); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); var values; values = "email=" + document.getElementById("logemail").value; values = values + "&password=" + document.getElementById("logpassword").value; xhr.send(values); xhr.onreadystatechange = function () { xhr.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200) { if (this.responseText == 'success'){ window.location.href = "forme.local/user.php" } else { document.getElementsById('logerror').innerHTML = this.responseText; } } } } }
In addition to this function, there are many others in this js file and they all work, and all also deal with ajax html requests:
<div id="login"> <p id="logerror" style="display:none;"></p> <form action="javascript:void(null);"> <p class="errors conferr"></p> <input id="logemail" name="logemail" type="text" placeholder="Email"> <input id="logpassword" name="logpassword" type="password" placeholder="Пароль"> <input class="regbutton" type="submit" onclick="login();" name="login" value="Войти"> </form> </div> HELP !!! What is the problem?