title: Passing parameters to express node.js via java script
body: <p>I am using javascript,html,nodejs,express and mysql to retrieve values from database and pass it back to html .  </p>
  
  <p>Here , the user enters a domain in the 'btnSearch' text box and presses Load button . The javascriot calls the /getallusers code in app.js . This function should access the database and return the result .</p>
  
  <p>The problem i am facing is : i am not able to pass on the value in 'btnSearch' to the app.js . If i include the  tags in html , then the request does not go to /getallusers .instead it goes to /hi.html?input=Music . So i have not used the  tag .</p>
  
  <p><strong>The html page is as below :</strong><br>
      
      
      var xmlDoc = null ;</p>
  
  <pre><code>function load() {
  var str = document.getElementById('btnSearch');
  alert(str);
  if (typeof window.ActiveXObject != 'undefined' ) {
    xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
    xmlDoc.onreadystatechange = process ;
  }
  else {
    xmlDoc = new XMLHttpRequest();
    xmlDoc.onload = process ;
  }
  xmlDoc.open( "GET", "/getallusers?input="+str, true );
  xmlDoc.send( null );
  }
  
  function process() {
  if ( xmlDoc.readyState != 4 ) return ;
  document.getElementById("output").value = xmlDoc.responseText ;
  }
  }&lt;/script&gt;&lt;body&gt;
  &lt;input type="text" name="input" id="btnSearch" /&gt;
  &lt;textarea id="output" cols='70' rows='40'&gt;&lt;empty&gt;&lt;/textarea&gt;
  &lt;br&gt;&lt;/br&gt;
  &lt;button onclick="load()"&gt;Load&lt;/button&gt; 
  &lt;button onclick="empty()"&gt;Clear&lt;/button&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>My express function is :</strong> </p>
  
  <pre><code>    app.get('/getallusers', function (req, res) {
      var input_domain=req.query.input;
      console.log(input_domain);
      connection.query('SELECT DBName FROM CrawlerDBInfo where Domain ='+"'"+input_domain+"'"+';', function (error, rows, fields) {
          res.writeHead(200, {
              'Content-Type': 'text/plain'
          });
          str = '';
          for (i = 0; i &lt; rows.length; i++)
          str = str + rows[i].DBName + '\n';
          res.end(str);
      });
  });
  </code></pre>