title: Ajax only return readyState == 4 value
body: <p>Ok I've looked everywhere for this. I'm cutting out a couple of the variable declarations, as I can ensure that my XMLHttpRequest is working.</p>
  
  <pre><code>function submit_edit_form()
  {
      // id and title are already declared
      var x = ajax_edit_form_save(id, 'title', title);
      alert(x);
  }
  function ajax_edit_form_save(id, property, new_value)
  {
  
      if (window.XMLHttpRequest)
      {
          xmlhttp = new XMLHttpRequest();
      }
      else
      {
          // screw IE5 &amp; IE6
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange = function()
      {
         if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.responseText != '')
         {    
              return xmlhttp.responseText;
         }
      }
  
      // myURL is already defined. I'm not troubleshooting this part, I know it's working
      xmlhttp.open("GET", myURL, true);
      xmlhttp.send();
  }
  </code></pre>
  
  <p>So when I call submit_edit_form(), which calls ajax_edit_form_save(), I get an alert 'undefined'. I know that the problem is that ajax_edit_form_save() is returning undefined on readyState 1. I'm scratching my head because I only have the return when readyState == 4. How can I hold off on the return value so that x gets the actual responseText?</p>