title: onreadystatechange function never gets called
body: <p>Ok...so my code is very simple. The only problem is that the function to be called onreadystatechange is never getting executed. I put in an alert to display the readyState and the status of xmlhttp which displayed it as 1 and 0 respectively. I cannot understand why the state is not changing. Also i do know for sure that everything else works fine. I put in alert boxes to display the username that i'm taking from the form...it displays it properly. Please help me out here....i just cannot figure this out...</p>
  
  <pre><code>function checkAvailability() {
      var xmlhttp;
      if (window.XMLHttpRequest) {
          xmlhttp = new XMLHttpRequest();
      } else {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      if (xmlhttp) {
          var regform = document.getElementById("regform");
          var username = regform.username.value;
          xmlhttp.open("POST", "http://localhost:8080/UsernameAvailability", true);
          xmlhttp.onreadystatechange = function() {
              alert(xyz);
          }
          xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          xmlhttp.send("username=" + username.value);
      }
  }
  </code></pre>