Thats my code I tried so Far:
so when I clicked on the a-link (which has a class '.like'), I want the ( '.PostlikeCount' [found in the div.postInfo]) to display the new total like amount.
$(".like").click(function(e) {
e.preventDefault()
$.ajax({
method: "GET",
url: $(this).attr("href"),
success: function(response) {
console.log(response)
$(this).parents("div.row").prevAll().first().find("span.PostlikeCount").html(response.total_likes)
}
});
});
<div class="row postInfo">
<small class="font-weight-light col-8 ">
<span class="PostlikeCount">{{post.likePost.count}}</span> people like this
</small>
<small class="font-weight-light ml-3 viewAll"><a href= "#">view all comment</a>
</small>
</div>
<hr>
<div class="mt-2 row">
<span class="col-9 postLike">
<a href="{%url 'likes:like_Post' post_id=post.id location='homePage'%}" class="d-inline-block like">
<span><i class="far fa-heart "></i> Like</span>
</a>
</span>
</div>