I have a page with two select menus and a table to display data. I fetched the data with 'get' from MySQL and populated the select menu, now when I click on the 'submit' button, it should display the data in the table below without refreshing the page. I am new to this.
App.js
app.get('/home', function(req, res){
db.connect(function(err){
var sale = req.query.cbosale;
var company = req.query.cbocompany;
db.query("SELECT DISTINCT(SaleNo) FROM tsales; SELECT DISTINCT(Company) FROM tcompany; SELECT * FROM trecords WHERE SaleNo = '"+sale+"' AND Company = '"+company+"'", [1,2,3], function(err, result, fields){
res.render('home', {title:"Home",data:result});
})
})
})
Home.jade
script.
$('#submit').click(function(){
var cbosale = $('#cbosale').val();
var cbocompany = $('#cbocompany').val();
$.get("/home", {cbosale: cbosale, cbocompany: cbocompany), function(data){
$('#showdata').show();
})
})
})
When I insert static variables in the query, the data gets displayed, passing params doesn't display it. Might be an issue when fetching the params.