partial page refresh

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghavendrachar
    New Member
    • Oct 2011
    • 1

    partial page refresh

    Hi,
    I am doing you-tube like/dislike script for my web page having comments given by user and other users may like or dislike the comments.

    I want to do is that when user click on like or dislike images , it automatically update the database and update the counter on web-page with out refresh.

    Code:
    <script type="text/javascript">
    $(document).ready(function()
    {
    $(".like").click(function()
    {
    var id=$(this).attr("id");
    var name=$(this).attr("name");
    var dataString = 'id='+ id + '&name='+ name;
    $("#votebox").slideDown("slow");
    
    $.ajax
    ({
    type: "POST",
    url: "rating.php",
    data: dataString,
    cache: false,
    success: function(html)
    {
    $(#refreshelement).load();
    } 
    });
    });
    });
    </script>
    <div id="refreshelement">
    <?php getting data form database ?>
    <div><a class="like">like</a><?php get count like?></div>
    <div><a class="like">dislike</a><?php get count like?></div>
    </div>
    this is the code I am using for auto update database and auto refresh .. here update to the database is coming but auto refresh is not happening.

    could any one help me in this issue.
    Last edited by Meetee; Oct 31 '11, 05:12 AM. Reason: code tags added
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Put quotes around "#refreshelemen t" on line 19.

    Also, use the html variable to set the results. There's an example on the jQuery.post page.

    Comment

    Working...