JSFiddle - React, Tailwind, and code Playground

by thomas_david88

HTML

<div class="post" postid="10">
    <input type="button" class='like' value="LikeButton" /> </input>
    <input type="button" class='dislike' value="DislikeButton"> </input>
</div>

JavaScript

$(function () {
  $('.like').click(function () { likeFunction(this); });
  $('.dislike').click(function () { dislikeFunction(this);});
});


function likeFunction(caller) {
  var postId = caller.parentElement.getAttribute('postid');
  console.log(postId);
  $.ajax({
      type: "POST",
      url: "rate.php",
      data: 'Action=LIKE&PostID=' + postId,
      success: function () {}
  });
}
function dislikeFunction(caller) {
  var postId = caller.parentElement.getAttribute('postid');
    console.log(postId);
  $.ajax({
      type: "POST",
      url: "rate.php",
      data: 'Action=DISLIKE&PostID=' + postId,
      success: function () {}
  });
}