0

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.

Community
  • 1
  • 1
Łukasz Baran
  • 1,229
  • 3
  • 24
  • 47

1 Answers1

0

First of all: Do not post information using the GET verb. It's a violation of the HTTP specification.

It would be nice if you could describe the error that you get, instead of just saying "it doesn't work".

An educated guess would be that the code used to find the postID do not work. Can you add an alert in the function and let it show the postID?

And what is sb that you are talking about?

jgauffin
  • 99,844
  • 45
  • 235
  • 372