title: Send a POST XMLHttpRequest with a body to an express node server
body: <p>Basic background:</p>
  
  <p>I have an express node server running a really simple website. The first page of the site has two inputs (1 text, 1 number) </p>
  
  <pre><code>&lt;input type="text" name="xml_url" id="xml_in" placeholder="Required" /&gt;
  &lt;input type="number" min="0" name="c2" id="c2_in" placeholder="Required" /&gt;
  </code></pre>
  
  <p>As of right now really simple, the user inputs a url and a number, my app builds something and returns a link to a file.</p>
  
  <p>My node server (basically) looks like this: </p>
  
  <pre><code>app.post('/secondPage', function(req, res){
   var url = req.body.xml_url
     , c2 = req.body.c2;
   //some stuff happens etc...
  res.render('finalpage.html', {
      foo: c2andsomething
      url: newurl
   });
  </code></pre>
  
  <p>My Question/Issue:</p>
  
  <p>I want to be able to not use my front end. I believe the code  will basically work (besides the render, I believe I will need something along the lines of </p>
  
  <pre><code>res.send(aJsonResponse); // obviously I will need to build the json
  </code></pre>
  
  <p>I just don't know how I can fake this post request. I'm sort of drawing a blank here. So far I've only really tried a few websites that claim they'll send a post request etc.. and tried in the browser just typing in my url with a query string, but my app doesn't accept GET.. </p>
  
  <p>Hopefully this wasn't too much rambling, but I would love to hear some suggestions. Will remove if this question makes no sense.</p>
  
  <p>EDIT: </p>
  
  <p>Okay so I always seem to jump the gun with these questions. I just tried in the console: </p>
  
  <pre><code>var xmlhttp = new XMLHttpRequest();
  xmlhttp.open("POST", "http://192.168.1.1:3000/secondPage", true);
  xmlhttp.send("foobar");
  </code></pre>
  
  <p>And I'm getting a CORS error.. I think I'll be able to figure this out here shortly, if you have any suggestions I would still really love to hear them. </p>
  
  <p>Thanks</p>
  
  <p>EDIT 2: </p>
  
  <p>So I'm able to send the request and such no CORS issues.. but I'm not sure how to set the body in the request.</p>
  
  <pre><code> var xmlhttp = new XMLHttpRequest();
   xmlhttp.open("POST", "http://192.168.1.1:3000/secondPage", true);
   xmlhttp.send({"xml_in":"I-thought-this-was-the-body"});
  </code></pre>
  
  <p>but req.body is <code>{}</code></p>