I am trying to remove a div from my page once i receive an XMPHttpRequest response. I have also tried setting the display of the div to none using: document.getElementById('password').style.display = 'none'; but that didnt work either.
HTML:
 <div class="login-container">
      <div class="title">Login Form</div>
      <div class="form-fields" id="form-fields">
           <form name="login_form" method="post" id="login-form" onsubmit="return submitForm()">
                <input type="text" name="username" id="username" placeholder="Username" required></input>
                <input type="password" name="password" id="password" placeholder="Password" required></input>
                <input type="submit" value="Log in" id="submit-button"></input>
                <input id="sessionID" class="hidden"></input>
           </form>
      </div>
      <div id="success-message" class="hidden">Congratulations! You have been logged in.</div>
      <button id="logout" class="hidden"></button>
 </div>
Javascript Function:
 function sendLoginInfo() {
      var loginRequest = new XMLHttpRequest();
      loginRequest.open("POST", "server/login.php", false);
      loginRequest.setRequestHeader('Content-type', "application/json");
      loginRequest.onreadystatechange = function () {
           if(loginRequest.readyState == 4 && loginRequest.status == 200) {
                sessionID = keyRequest.responseText;
                var el = document.getElementById( 'password' );
                el.parentNode.removeChild( el );
           }
      }
      loginRequest.send(JSON.stringify(JSONFormData));
 }
Update
This problem was solved by changing:
<form name="login_form" method="post" id="login-form" onsubmit="return submitForm()">
To:
<form name="login_form" method="post" id="login-form" onsubmit="submitForm(); return false;">
 
     
    