Im building a web page with node,express and mongodb. Im trying to make a like button, but the problem is I cant pass a variable value from my ejs to my server side. how can I do that? here's what I've tried Exemple
Html
<div class="thumbnail">
<div class="caption">
<strong id="Title"><%=video.title %> </strong>
<button id="like" value="Like" type="submit">
<script>
var videoId =<%= video._id %>;
$('#like').click(function(){
$.post('/like/'+videoId);
});
</script>
Server side
router.post('/like/:videoId', function (req, res) {
var test = req.params.videoId;
console.log("works");
console.log(test);
});
thanks in advance