I am writing a simple application which is running on Nodejs. I am using centos. Front end is html and JavaScript. In the HTML page, I have 2 forms. On selection of data from form1 and clicking on a button, a table has to be loaded inside form2. I have managed to do this functionality with JavaScript. (For now I have used hard coded values.) If I were to retrieve values from database, how should I proceed? I am a noob in Nodejs ! I am processing all the requests using similar methods as below:
app.post('/DomainInfo', function (req, res) {
console.log("POST: ");
DOMAIN = req.body.DomainName;
LOCALE = req.body.locale;
connection.query('insert into DomainInterval ( Domain , Locale , ASRFrequency , NLUFrequency, Numinstances ) values (' + "'" + DOMAIN + "'" + ',' + "'" + LOCALE + "'" + ",'" + ASRFRQ + "'" + ',' + "'" + NLUFRQ + "'" + ',' + NONODES + ');', function (error, rows, fields) {
res.writeHead(200, {
'Content-Type': 'text/plain'
});
res.end('record inerted...');
});
connection.query('commit;');
console.log('success!');
});
// Launch server
app.listen(1213);
While calling these methods, the data retrieved form database is displayed on a separate page. I want it to be sent to the same html page from where the request was sent, sort of like an AJAX call. Is there any way to do this without PHP or servlet?