首页  >  文章  >  web前端  >  Voting System Javascript

Voting System Javascript

Barbara Streisand
Barbara Streisand原创
2024-09-22 16:30:39243浏览

Voting System Javascript

Working on a project here at jhoom.xyz and have stuck at a place where I would like to limit voting per IP.
` function voteReview(reviewId, voteType) {
const data = {
action: 'ipf_vote_review',
reviewId: reviewId,
voteType: voteType,
postId: ID; ?>
};

        jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
            if (response.success) {
                const reviewElement = jQuery('.single-review').eq(reviewId);
                if (voteType === 'up') {
                    let upCount = parseInt(reviewElement.find('.thumb:first').text().match(/\d+/)[0]) + 1;
                    reviewElement.find('.thumb:first').html('&#128077; (' + upCount + ')');
                } else {
                    let downCount = parseInt(reviewElement.find('.thumb:last').text().match(/\d+/)[0]) + 1;
                    reviewElement.find('.thumb:last').html('&#128078; (' + downCount + ')');
                }
            } else {
                alert(response.data);
            }
        });
    }

`

以上是Voting System Javascript的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn