I need help to change my html index to EJS.
I'm using Node, and I've 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 this is 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 properly, but now I want to mix the js with the html.
In my configuration file I have this:
app.get ('/', function (req, res) {res.render ('index', {title: 'DATA BASE'});});
If someone can help me, or at least give me a direction, because I have no idea how to use EJS.
Thank you.