title: Pass ajax value to a variable in node.js server
body: <p>I have an ajax get request that has a data of an input. I want to pass this data into a variable and use it in my query.</p>
  
  <p>index.handlebars</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;input type="hidden" class="test" name="test" value="sample"/&gt;
          &lt;script type="text/javascript"&gt;
              $( document ).ready(function() {
                  var username = $('.test').val();
                  $.ajax({
                      type : 'GET',
                      url: '/users//welcome',
                      data : {
                          wew: username
                      }
                  });
                  alert(username); //correct output
              });
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and in my users/welcome </p>
  
  <pre><code>router.get('/welcome', ensureAuthenticated, function(req, res){
  
      var test = req.query.wew; //data from ajax request
  
      Item.find({username: test},function(err, docs, test){    
          //where username is the data
          console.log(test);
          res.render('welcome', {docs:docs});
      });
  });
  </code></pre>
  
  <p>This code is not working. Please help :/</p>