Submit form values to a node JS method and display result on the same page
<p>What I want is that when the user taps the submit button, the email field to be sent to the server and then return the result (If email saved in DB or not) on the same page.</p>

<p>My code :</p>

<pre><code>&lt;form id="mc-form"   action="http://local_host:8081/ttttt" method="post" enctype="multipart/form-data"&gt;
   &lt;input type="email" value="" name="dEmail" class="email" id="mc-email" placeholder="type email &amp;amp; hit enter" required=""&gt; 
   &lt;input type="submit" name="subscribe" &gt;
   &lt;label for="mc-email" class="subscribe-message"&gt;&lt;/label&gt;
&lt;/form&gt;
</code></pre>

<p>However, unless I remove <code>id="mc-form"</code> from the above code the values does not get passed to the server. If I remove <code>id="mc-form"</code> then there's a new page displayed with the result of the operation. However, I only want to display the result on the same page.</p>

<p>Node JS code as follows:</p>

<pre><code>app.post('/ttttt', function (req,res){
    console.log('Came in');
    var form = new formidable.IncomingForm();

    form.parse(req, function (err, fields, files) {
        //Store the data from the fields in your data store.
        //The data store could be a file or database or any other store based
        //on your application.
        res.writeHead(200, {
            'content-type': 'text/plain'
        });
        res.write('received the data:\n\n');
        res.end(util.inspect({
            fields: fields

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