I have somehow working solution, but not entirely. I can updates send data and receive it, but I have don't any idea how to display it.
We have thread, and in thread there is bunch of posts. What I want to do is to make partial updates for posts that user voted. Now question is how to do it ?
$(".like").click(function () {
var postID = $(this).parents('span.likeDislike').attr('id').split('_')[1];
var vote = $(this).attr("id");
var name = $(this).attr("name");
var dataString ='PostID='+postID+'&Name='+name+'&Vote='+vote;
$.ajax
({
type: "GET",
url: "/Forum/Post/LikePost",
data: dataString,
cache: false,
success: function (html) {
$('#postID_' + postID).html(html);
}
});
});
<span class="likeDislike" id="@sb.ToString()">
<a href="#" class="like" name="up">Like</a>
/
<a href="#" class="like" name="down">Dislike</a>
<span>@Model.Post.Like</span>
</span>
Something like this is not working. sb is just post_POSTID_FROM_DB and each post whave it own span with the same id. But this doesn't inject any html into it.
I found this: How can you make a vote-up-down button like in Stackoverflow? Infact i did it based on this, but doesn't help with my partial update issue.