1
I need help changing my html index to EJS.
I am using Node, and I have already made the changes in my configuration file for EJS to work properly.
In my index.ejs I have a table tr:
<div class="container">
<div class="starter-template">
<table class="table">
<thead>
<tr>
<th>✓</th>
<th>ID</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
And that’s the script tag before the end of the body:
$.ajax({ type: 'GET', url: 'https://myapp.com/reservations', crossDomain: true, success:function(reservations){
reservas.forEach (function (data) {
var reservation = [];
reservation.push('<tr class="reservas">');
reservation.push('<td> <input type="checkbox" name="checkbox"/></td>');
reservation.push('<td>' + data._id + '</td>');
reservation.push('<td>' + data.nome + '</td>');
reservation.push('<td>' + data.email + '</td>');
reservation.push('</tr>');
$('tbody').append(reservation.join(""));
});
},
error:function(e){
console.log(e);
}
});
It’s working correctly, but now I want to mix js with html.
In my configuration file I have this:
app.get('/', Function(req, res) { res.render('index', { title: 'DATA BASE' }); });
If anyone can help me, or at least give me a direction, because I have no idea how to use the EJS.
Thank you.
Thank you, very well explained ooredpurple.
– user14869