I am trying to pass array of objects from backend to front end.
app.js
router.post('/submits',urlencodedParser,function(req,res)
{
//getLocation function returns an array of objects
getLocation(req.body.latval,req.body.longval)
res.redirect('./table');
});
router.get('/table',function(req,res)
{
res.render("table");
});
table.js (front end)
window.onload= table();
function table(array)
{
var table = document.getElementById("table");
for(var i = 0;i<table.rows.length;i++)
{
for(j=0;j<table.rows[i].cells.length;j++)
{
table.rows[i].cells[j].innerHTML = array[i][j];
}
}
});
So I am trying to send the array as a parameter to the function in table.js. How can I do it?
http get, use$.ajax.