开发者

JQuery Voting issue

开发者 https://www.devze.com 2023-02-07 05:38 出处:网络
I voting to news author in my site with this jQuery code. <script type=\"text/javascript\"> $(function() {

I voting to news author in my site with this jQuery code.

<script type="text/javascript">
    $(function() {
        $(".vote").click(function() 
        {
            var id = $(this).attr("id");
            var name = $(this).attr("name");
            var dataString = 'id='+ id ;
            var parent = $(this);

            if (name=='up')

            {
                $(this).fadeIn(200).html('<img src="dot.gif" />');
                $.ajax({
                    type: "POST",
                    url: "up_vote.php",
                    data: dataString,
                    cache: false,

                    success: function(html)
                    {
                        parent.html(html);
                    } 
                });

            }
            else
            {
                $(this).fadeIn(200).html('<img src="dot.gif" />');
                $.ajax({
                    type: "POST",
                    url: "down_vote.php",
                    data: dataString,
                    cache: false,

                    success: function(html)
                    {
                        parent.html(html);
                    }
                });

            }
            return false;
        });
    });
</script>

This worked ! After voting show alert box for thanks or result. Now if in one page 9 posts (开发者_Python百科 example ADMIN posted ) for voting 9 show 9 alert box !

How to fix this ?


You can use this one: http://www.technabled.com/2011/02/pulse-lite-reddit-ajax-up-down-voting.html Disclosure: I am the developer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号