title: readyState will not change to 4
body: <p>I am trying to create a dynamic AJAX search bar which communicates with my database. Here is my code. </p>
  
  <pre><code>function getXmlHttpRequestObject(){
  if(window.XMLHttpRequest){
      return new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
      return new ActiveXObject("Microsoft.XMLHTTP");
  }
  else{
      alert("Your browser does not support our dynamic search");
  }
  }
  
  var search = getXmlHttpRequestObject();
  
  function ajaxSearch(){
      if (search.readyState == 4 || search.readyState == 0){
          var str = escape(document.getElementById('searchBox').value);
          search.open("GET", 'searchSuggest.php?search=' + str, true);
          search.onreadystatechange.handleSearchSuggest;
          search.send(null);
      }
  }
  
  function handleSearchSuggest(){
      if(search.readyState == 4){
          var ss = document.getElementById('ajaxSearch');
          ss.innerHTML = '';
          var str = search.responseText.split("\n");
          for(i=0; i&lt;str.length-1; i++){
              var suggestion = '&lt;div onmouseover="javascript:suggestOver(this);"';
              suggestion += 'onmouseout="javascript.suggestOut(this);"';
              suggestion += 'onclick="javascript:setSearch(this.innerHTML);"';
              suggestion += 'class="suggestLink"&gt;' + str[i] + '&lt;div&gt;';
              ss.innerHTML += suggestion;
          }
      }
  }
  
  function suggestOver(divValue){
      divValue.className = "suggestLink";
  }
  
  function suggestOut(divValue){
      divValue.className = "suggestLink";
  }
  
  function setSearch(x){
      document.getElementById('searchBox').value = x;
      document.getElementById('ajaxSearch').innerHTML = '';
  }
  </code></pre>
  
  <p>The problem is that the readyState is changing from 0 to 1, but then it will not change to any other state. I need it to change to 4 to enter the function <strong>handleSearchSuggest()</strong>.
  I also get this error within the console:
  <strong>TypeError: search.onreadystatechange is null</strong></p>