title: AJAX setTimeout not working when pass through parameters
body: <p>The user inputs something then using ajax the program outputs something to the user. Which mostly works, the problem is passing variables through parameters to the remote function from my script. </p>
  
  <p>The <code>setTimeout</code> call messes up when I pass the text in as a parameter. But when I type it in <code>setTimeout</code> function itself, it works:</p>
  
  <pre><code>function handleServerResponse(text){
      if(xmlHttp.readyState==4){ 
          if(xmlHttp.status==200){
              xmlResponse = xmlHttp.responseXML; //izvlaci se xml sto smo dobili
              xmlDocumentElement = xmlResponse.documentElement;
              message = xmlDocumentElement.firstChild.data;
              document.getElementById('underInput').innerHTML = message;
              setTimeout("process(text)", 1000);
          }else{
              alert('Someting went wrong !');
          }
      }
  }
  </code></pre>
  
  <p>The whole code:</p>
  
  <pre><code>&lt;script type = "text/javascript"&gt;
  
  var xmlHttp = createXmlHttpRequestObject();
  
  function createXmlHttpRequestObject(){
      var xmlHttp;
  
      if(window.ActiveXObject){ 
          try{
              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
          }catch(e){
              xmlHttp = false;
          }
      } else { 
          try{
              xmlHttp = new XMLHttpRequest();
          }catch(e){
              xmlHttp = false;
          }
      }
  
      if(!xmlHttp)
          alert("Cant create that object !")
      else
          return xmlHttp;
  }
  
  function process(text){
  
      //text = 'userInput';
  
      if(xmlHttp.readyState==0 || xmlHttp.readyState==4){
          food = encodeURIComponent(document.getElementById(text).value);
          xmlHttp.open("GET", 'foodstore.php'+"?food="+food,true);
  
          xmlHttp.onreadystatechange = function() {
              handleServerResponse(text);
          };
  
          xmlHttp.send(null);
      }else{
          setTimeout("process(text)",1000);//cekaj 1s pa probaj opet
      }
  }
  
  function handleServerResponse(text){
  
      if(xmlHttp.readyState==4){ 
          if(xmlHttp.status==200){
              xmlResponse = xmlHttp.responseXML; //izvlaci se xml sto smo dobili
              xmlDocumentElement = xmlResponse.documentElement;
              message = xmlDocumentElement.firstChild.data;
              document.getElementById('underInput').innerHTML = message;
              setTimeout("process(text)", 1000);
          }else{
              alert('Someting went wrong !');
          }
      }
  }
  
  &lt;/script&gt;
  
  //*******************************************
  
  &lt;html&gt;
      &lt;body onload = "process('userInput')"&gt;
          &lt;h3&gt;The Chuff Bucker&lt;/h3&gt;
          Enter the food you would like to order:
          &lt;input type="text" id="userInput" /&gt;
          &lt;div id="underInput" /&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>