I have started learning web development. I was using forms in express with ejs. when I click on submit button the entire page refreshes. Is there any way I can prevent the page refresh. I saw other answers over here. When I use type="button" the answer data typed in form is not being submitted.
Here tweet is a list passed from main js page. when the form is submitted I would be using body-parser to collect button value.
<% tweet.forEach(item=>{ %>
<form action="/home" method="post">
<div class="tweets">
<span> <%= item.name %></span><br>
<span> <%= item.data %></span><br>
<button type="submit"
name="like"
value="<%= item.name %>"
<i class="fa fa-thumbs-up" aria-hidden="true"> </i>
</button>
</div>
</form>
<% }) %>
Kindly help. Thank you