Rating system with jQuery, PHP and SQL: Passing rated value from javascript to PHP
I'm meeting huge problems while creating a rating system for 开发者_StackOverflow社区my website. I have no problem with PHP, but with Javascpit and jQuery.
My intentions are to give the rated value to PHP, and, also give some other variables that are into the page URI (like: ?pg=try&id=2
).
Here what I do (and it work) util now:
$(document).ready(function(){
// START the RAtings script
$('.ratingStars').hover(
// Mouse Hover
function() {
$(this).prevAll().andSelf().addClass('overStar');
$(this).nextAll().removeClass('voteStar');
},
// Handle teh mouseout
function() {
$(this).prevAll().andSelf().removeClass('overStar');
set_votes($(this).parent());
}
);
// This make al clicable
$('.ratingStars').bind('click', function() {
////// HERE THE CODE TO PHP
});
});
I also need to know how to pass variables from PHP to Javascript...
Thanks in advice.
You will need to use AJAX to make a request to the backend. Have a look at http://api.jquery.com/jQuery.ajax/
精彩评论