Two different POST requests being made to the same route at the same time
<p>I am creating a voting app and I have an issue that I don't know how to work around. I think I have just structured my app badly. I have a POST route like so </p>

<pre><code>app.route('/poll-create')
        .post(function(req, res) {
            var userID; //variable to store the authentication id for the user
            var incoming_id = Object.keys(req.body)[0];

            console.log(incoming_id);

            serverHandler.newPoll(req, res, db, function(id) {
                user_id = id;
            });

            res.redirect('/new-poll');


        });
</code></pre>

<p>I am passing in some form data to this route like so from the HTML</p>

<pre><code>&lt;form action='' method='post' enctype='multipart/form-data' name='new-poll-form'&gt;
                    &lt;div class='form-group'&gt;
                        &lt;label&gt;Title&lt;/label&gt;
                        &lt;input type='text' name='title' class='form-control' placeholder='Title' /&gt;
                    &lt;/div&gt;
                    &lt;div class='form-group'&gt;
                        &lt;label&gt;Options&lt;/label&gt;
                        &lt;textarea class="form-control poll-options" rows="5" placeholder='Options' name='options'&gt;&lt;/textarea&gt;
                    &lt;/div&gt;
                    &lt;button type='submit' class='btn btn-primary submit-butt'&gt;Submit&lt;/button&gt;
                   &lt;/form&gt;
</code></pre>

<p>The data entered in the form is directly sent to the route with no need for an AJAX request on my part. I assume this is because I am setting the method='post' in the form. </p>

<p>Now, my problem is that I also need to pass in an object from the JavaScript file linked to the above HTML file. I am doing that through an AJAX call like so </p>

<pre><code>$('.submit-butt').on('click', function() {
                        console.log('From in here');
                        ajaxFunctions.ready(ajaxFunctions.ajaxRequest('POST', appUrl + '/poll-create', response.authResponse.userID, function(data) {

                        }));
                    });
</code></pre>

<p>Here is the AJAX function below </p>

<pre><code>'use strict';
var appUrl = window.location.origin;

var ajaxFunctions = {
  ready: function ready (fn) {
      if (typeof fn !== 'function') {
         return;
      }

      if (document.readyState === 'complete') {
         return fn();
      }

      document.addEventListener('DOMContentLoaded', fn, false);
  },
  ajaxRequest: function ajaxRequest (method, url, data, callback) {
      var xmlhttp = new XMLHttpRequest();
      console.log('Inside ajaxRequest');
      console.log(data);

      xmlhttp.onreadystatechange = function () {
         if (xmlhttp.readyState === 4 &amp;&amp; xmlhttp.status === 200) {
            callback(xmlhttp.response);
         }
      };

      xmlhttp.open(method, url, true);
      xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
      xmlhttp.send(data);
  }
};
</code></pre>

<p>So, the first issue I face is that when I try console.log the data sent through the AJAX request (assuming I send in an object), the output I get is {'object Object': ' '}. Which is why I opted to send in only the userID from that object. In that case I get this, {'userID': ' '}. Its annoying but I can work with it at the very least. </p>

<p>My second issue is that, even if I work my way around the first issue, I am essentially making two AJAX calls to the same route. So, I don't have access to the form data and the userID at the same time. So, I can't insert them into a single document. How do I work my way around this? Is there a better way of passing around data than I am doing currently? Please help! 
I am using body-parser to parse incoming data and formidable to parse incoming form-data. </p>