Right now I have 2 buttons, one calls a function to do something and the other displays info onto the page.
router.get('/run-func', function(res, req, next) {
//call function
res.render('index');
};
router.get('/get-data', function(res, req, next) {
//get info from db...
res.render('index', {items: tempArray});
};
Each time a button is clicked it sends me to another url but displays the index page:
http://localhost:3000/run-func
http://localhost:3000/get-data
The problem is every time I click run-func it reloads the page and the data that was displayed from get-data disappears. Is there a way to make these buttons not load different urls?
The HTML was done using handlebars, here's the get-data one:
<div class="get">
<h3>Get Data</h3>
<a href="/get-data">LOAD DATA</a>
<div>
{{# each items }}
<article class="item">
<div>id: {{ this._id }}</div>
<div>prop: {{ this.prop }}</div>
</article>
{{/each}}
</div>
</div>