I'm making a little bit complex page using EJS and Express.JS. I'll simplify it a little:
First application loads /update the easy way and renders it:
app.get('/update', (req, res) => {
res.render('update');
});
update in render function is an EJS template. Here's how it looks like:
...
<div id="progress"></div>
<button id="perform" type="button" class="btn btn-default">Download & Update</button>
<script>
$('#perform').click(function() {
$('#perform').hide();
$('#progress').load('/perform');
});
</script>
...
As you can see on button click, application loads /perform express.js route into specific div. Here's what it does on Node.JS side:
app.get('/perform', function(req, res) {
//Renders div
res.render('perform')
//Does some actions in 1-2 minues.
//Here I want it to redirect to / of application.
});
After it returns some content using res.render(), application starts doing some processes. They take about 1 minute and after completion I want application to redirect to /. I've tried using res.redirect('/') e.t.c., but nothing works. Maybe somehow it should tell browser to redirect..
What can I do here?