I'm using nodejs to develop a website that extract data from an API using ajax requests. I use templates, .hbs files (index.hbs, area.hbs etc.). My problem is that I want to make a navbar (with text links), but since I use templates its not that easy. I need to use ajax. I have made all the necessary routes, but I need help with the ajax request on the links. I have searched the internet for an answer, and tried a lot of different solutions, but nothing seems to solve my problem.
My navbar code:
<div id="navbar">
<ul>
<li>Companies</li>
<li>Area</li>
</ul>
</div>
Server.js route code:
app.get('/area', routes.goToArea);
Routes.js code:
goToArea: function (req, res) {
res.render('area');
}
I think something along those lines could work:
var url = "/area";
function area() {
$.ajax({
url: url,
type: 'GET',
Any help would be greatly appreciated!