title: Ajax call to servlet, get parameter
body: <p>I'm calling my Java Servlet with an AJAX call, but I'm not able to read the input parameter from the request. I've tried two ways but with no luck:</p>
  
  <pre><code>var id;
  $("#scan").click(function() {
      id = 1;
      $.ajax({ 
          type: "POST",
          data: id,
          url: "http://10.1.42.249:8080/test-notifier-web/RestLayer"
      });
  });
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>id = 1;
  $.post('http://10.1.42.249:8080/test-notifier-web/RestLayer', {
      reqValue: id
  }, function(responseText) { 
      // $('#welcometext').text(responseText);
      alert("OK!!!");
  });
  </code></pre>
  
  <p>My servlet code is a simple log print of the request parameter, but the return value is always null:</p>
  
  <pre><code>String reqID = "";
  log.info("Servlet called");
  reqID = request.getParameter("reqValue");
  log.info("reqID = " + reqID);
  </code></pre>
  
  <p>How can I get this working?</p>
  
  <p>The only way I've found to get the code working is manually add the parameter to servlet url, like <code>http://10.1.42.249:8080/test-notifier-web/RestLayer?reqValue=1</code></p>