我正在尝试建立一个评级系统,需要从文件 startating.php 调用一个函数并在那里传递变量 - $id(post id)和评级百分比。我不知道如何调用这些变量,然后在 startating.php 中引用它们这是我的代码:
$( function() {
var postID = <?php echo $id; ?>;
var rating = new starRating( { // create first star rating system on page load
containerId: '$id', // element id in the dom for this star rating system to use
starWidth: 60, // width of stars
starHeight: 60, // height of stars
ratingPercent: '0%', // percentage star system should start
canRate: true, // can the user rate this star system?
user: '$userLoggedIn',
onRate: function() { // this function runs when a star is clicked on
//console.log( rating );
$.ajax({
url: '../handlers/starating.php',
type: 'POST',
data: 'post_id='+postID+'&rating_num='ratingPercent,
dataType: 'json',
success: function(){
console.log('works');
}
});
//alert('You rated ' + rating.newRating + ' starts' );
}
} );
} );
叮当猫咪
qq_花开花谢_0
LEATH
随时随地看视频慕课网APP