Javascript 刷新查询数据库


Javascript refresh query database?

这是网站:在此处输入链接说明

现在这是函数:

$("a.wtf").click(function(){
//get the id
the_id = $(this).attr('id');
// show the spinner
$(this).parent().html("<img src='images/thanks.fw.png'/>");
//the main ajax request
    $.ajax({
        type: "POST",
        data: "action=wtf&id="+$(this).attr("id"),
        url: "votes.php",
        success: function(msg)
        {
            $("span#votes_count"+the_id).fadeOut();
            $("span#votes_count"+the_id).html(msg);
            $("span#votes_count"+the_id).fadeIn();
            $("span#vote_buttons"+the_id).remove();
        }
    });
});

这是其余的:

<a href='javascript:;' class='wtf' id='".$list['id']."'>

改写:现在,它在用户投票"WTF"后显示图像。我将如何将投票链接替换为显示 WTF 投票新值的新文本(可能是查询的结果)

发送投票后.php,希望您正在更新或插入新的投票,如果发生这种情况,就像我提到的这意味着,您还从 db 获取新插入或更新的值,然后返回到回调函数

例:


    $total_votes=100;
    $reuslut=$total."-".'Thanks for vote';
    echo $result;
    exit;
 in call back function :
 ---------------------
    success: function(msg)
    {
       var value=msg.split("-");
        $("span#votes_count"+the_id).fadeOut();
        $("span#votes_count"+the_id).html(value[1]);
        $("span#votes_count"+the_id).fadeIn();
        $("span#vote_buttons"+the_id).remove();
        $(selector).html(value[1]);
    }

希望它能帮助您解决问题