title: Need help to catch AJAX response
body: <p>I wrote the following code in my <code>home.php</code>.The <code>login()</code> function is called by clicking on submit button.</p>
  
  <pre><code> function login()
    {
      try{
        xmlHttp=new XMLHttpRequest();
      }catch(e){
        try{
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }catch(e2){
        try{
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e3){
  
        alert('Sorry ! AJAX not supported');
      }
      }
      }
      xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4&amp;&amp;xmlHttp.status==200){
          alert(xmlHttp.responseText);
        }
      }
      xmlHttp.open('POST','ajax_call.php',true);
      xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
      xmlHttp.send(document.getElementById('username').value,document.getElementById('password').value);
    }
    &lt;/script&gt;
  </code></pre>
  
  <p>My ajax_call.php script is simply </p>
  
  <pre><code>&lt;?
  echo 'hello';
  ?&gt;
  </code></pre>
  
  <p>I am not getting the alert <code>Hello</code>.Why?</p>
  
  <p>[I tried to alert <code>readyState</code> and <code>status</code> </p>
  
  <pre><code>xmlHttp.onreadystatechange=function(){
        alert(xmlHttp.readyState+" "+xmlHttp.status);
        if(xmlHttp.readyState==4&amp;&amp;xmlHttp.status==200){
          alert(xmlHttp.responseText);
        }
      }
  </code></pre>
  
  <p>and got following in sequence</p>
  
  <pre><code>1 0
  2 200
  3 200
  4 200
  hello
  1 0
  hello
  </code></pre>