title: Can't return xmlhttp.responseText?
body: <p>Any insight into the problem here? When run, the code yields nothing. No text appears on the page. If I uncomment the commented line, the xml results appear. Why can't I pass it as a variable? (I do get the alert, fyi, so the function is being called.)</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
             function loadXMLDoc(parameterString)
                 {
                     alert("loadXMLDoc has been called.");
                     var xmlhttp = new XMLHttpRequest();
  
                     xmlhttp.onreadystatechange=function()
                     {
                         if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
                         {
  
                    //document.getElementById("xmlResults").innerHTML = xmlhttp.responseText;
                                 alert("Got the response!");
                                 return xmlhttp.responseText;
                             }
                             else document.getElementById("xmlResults").innerHTML = "No results."
                         }
  
                         var url =  "http://metpetdb.rpi.edu/metpetwebsearchIPhone.svc?" + parameterString;
                     xmlhttp.open("GET",url,true);
                     xmlhttp.send();
                 }
          &lt;/script&gt;
  
  
  
          &lt;script type="text/javascript"&gt;
  
         $(function(){
  
          //left out irrelevant code which creates the var "parameters"
  
           var results = loadXMLDoc(parameters);
  
           document.getElementById("xmlresults").innerHTML = results;
  
         });
  
  
         &lt;/script&gt;
  
  
  &lt;body&gt;
  &lt;div id="xmlResults"&gt;&lt;/div&gt;
  &lt;/body&gt;
  </code></pre>