Home > Article > Web Front-end > 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('👍 (' + upCount + ')'); } else { let downCount = parseInt(reviewElement.find('.thumb:last').text().match(/\d+/)[0]) + 1; reviewElement.find('.thumb:last').html('👎 (' + downCount + ')'); } } else { alert(response.data); } }); }
`
The above is the detailed content of Voting System Javascript. For more information, please follow other related articles on the PHP Chinese website!