I have a EJS template that's used to display several steps:
- Display a button, that starts a process on the node.js backend
- Display information what's happening. This step has a duration of 10s.
- Display a textinput and button
Transitioning from step 1 to step 2 is easy: The button triggers a post request that returns the updated view with the new step
-value. I'm struggeling with the timed transition from step 2 to step 3. I either
- Need to update the HTML output to the client from the server
- Implement a
setTimeout();
in the EJS template.
Second option is maybe easier, but I'm not able to get something like
<% if (step == 2) { %>
<p>Step 2 is happening right now</p>
<%
setTimeout(function() {
step = step + 2;
}, 1000 )
%>
<% } %>
to work. This approach is not working for me, since the 10s start after the button from step 1 pressed.
Thanks in advance!