title: if (xmlhttp.readyState==4 && xmlhttp.status==200) in AJAX not executing
body: <p>I was trying ajax on my page. But it is not working as <code>if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)</code> is always false. I have alerted the values of <code>xmlhttp.readyState</code> and <code>xmlhttp.status</code>. There values are always 1 and 0 respectively for <code>xmlhttp.open</code> event and 4 &amp; 0 respectively for <code>xmlhttp.close</code> event.</p>
  
  <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  function captcha_check()
  {
      var code = document.getElementById("captcha").value;
      var url = "http://www.opencaptcha.com/validate.php?img='.$captcha_name.'.jpgx&amp;ans="+code;
      var xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=function() {
          alert(xmlhttp.readyState + " " + xmlhttp.status);
          if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
            document.getElementById("captcha_error").innerHTML=xmlhttp.responseText;
            return false;
          }
      }
      xmlhttp.open("GET","captcha_check.php?img=abc.jpg&amp;ans="+code,true);
      xmlhttp.send();
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>What the issue may be and how can I solve it and make the AJAX functioning. Thanks in advance.</p>