📜  喜欢和不喜欢功能 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:59.393000             🧑  作者: Mango

代码示例1
$(document).ready(function() {
    $(".options").on("click", function(){
        var id = $(this).attr("id");
        id = id.replace(/\D/g,'');
        var vote_type = $(this).data("vote-type"); 
        $.ajax({                
            type : 'POST',
            url  : 'vote.php',
            dataType:'json',
            data : {id:id, vote_type:vote_type},
            success : function(response){
                $("#vote_up_count_"+response.id).html("  "+response.vote_up);
                $("#vote_down_count_"+response.id).html("  "+response.vote_down);                
            }
        });
    });
});