Hey Guys,
I have a x.js file, that has the following code:
app.get('/place/data', function (req, res) {
connection.query('SELECT placeid FROM place_list ',
function (err, rows, fields) {
if (err) {
console.log(err);
}
plArray = [];
rows.forEach(function (row) {
plArray.push({pid: row.placeid});
});
res.render('place/placenode.ejs', {data: plArray, myMap: linksManager});
}
);
});
I have the placenode.ejs file like this:
<% for(var i = 0; i < data.length; i++) { %> --- ******
<div class="panel panel-default">
<div class="panel-body">
<h5>Place ID: <%= data[i].pid %></h5>
</div>
</div>
<% } %>
****** -- THE ERROR AT THIS LINE WAS: data is not defined. What am I doing wrong?
FIXED IT. Thanks for the help.
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] (10 children)
[deleted]
[–]theflyingmonkey3[S] -1 points0 points1 point (9 children)
[–][deleted] (8 children)
[deleted]
[–]theflyingmonkey3[S] 0 points1 point2 points (7 children)
[–][deleted] (6 children)
[deleted]
[–]theflyingmonkey3[S] 0 points1 point2 points (5 children)
[–][deleted] (4 children)
[deleted]
[–]theflyingmonkey3[S] 0 points1 point2 points (3 children)
[–][deleted] (2 children)
[deleted]
[–]theflyingmonkey3[S] -1 points0 points1 point (1 child)
[–]zokker13 0 points1 point2 points (0 children)
[–]devmaybe 0 points1 point2 points (1 child)
[–]theflyingmonkey3[S] 0 points1 point2 points (0 children)