1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| $(document).ready(function() {
var variable = location.search;
var variable = location.search.substring(1,location.search.length);
var variable = variable.substring(3);
var some_product_id=variable;
getRating(some_product_id);
function getRating(id){
$.ajax({
type: "GET",
url: "loco/rate-product.php",
dataType : 'json',
processData: false,
data: "do=getRate&product_id=" + id,
cache: false,
async: false,
success: function(result) {
avg=result.avg;
sum=result.count;
$("#votes").html;
$(".vote_count").html(sum + " vote(s)");
$('.rate').rating('select',avg);
},
error: function() {
alert("Error, please try again1");
}
});
}
$('.rate').click(function(){
$.ajax({
type: "GET",
url: "loco/rate-product.php",
dataType : 'json',
data: "do=rate&product_id=" + some_product_id + "&rate="+$(this).text(),
cache: false,
async: false,
success: function(result) {
avg=result.avg;
sum=result.count;
$("#votes").html("Average:" + avg);
$(".vote_count").html(sum + " vote(s)");
$('.rate').rating('select',avg);
$('input',this.form).rating('readOnly',true);
$('.rate').unbind('click');
},
error: function() {
alert("Error, please try again2");
}
});
});
}); |
Partager