title: Ajax responseText comes back as undefined
body: <p>I'm having problems with this piece of code; the return value comes back as 'undefined'. What's the problem?</p>
  
  <pre><code>var fx = null;
  xmlhttp.open("GET", URL ,false);
  xmlhttp.onreadystatechange=function() 
      {
          alert("enter func");            
      if (xmlhttp.readyState==4) 
          {
          if (xmlhttp.status == 200) 
              {                   
                  alert(fx);                  
                  fx = xmlhttp.responseText;
                  return fx;
              }
          else
              {
                  alert("Error" + xmlhttp.statusText);
              }
          }
      }
  </code></pre>
  
  <p>Newer code:</p>
  
  <pre><code>function getData(callback)
   {      
      xmlhttp.open("GET", URL ,false);
      xmlhttp.onreadystatechange=function() 
          {               
          if (xmlhttp.readyState==4) 
              {
              if (xmlhttp.status == 200) 
                  {                   
                      alert(xmlhttp.responseText);
                      cbfunc(xmlhttp.responseText);                   
                  }
              else
                  {
                      alert("Error" + xmlhttp.statusText);
                  }
          }
      }   
          xmlhttp.send(null);
   }
  </code></pre>
  
  <p>How I'm calling it:</p>
  
  <pre><code>getData( function cbfoo(txt)
           {
              //document.form.autodate.value=txt;
              alert(txt);
              alert(document.form.autodate.value);
           });`
  </code></pre>