2015-07-31 11:37:25 +02:00
|
|
|
$( document ).ready(function() {
|
|
|
|
$('.vote_box').on('click', '.vote', function(e){
|
|
|
|
var boxes = $(this).parent('.vote_box');
|
|
|
|
var id_post = $(this).data('id');
|
|
|
|
var uri = baseUri+'modules/cmsps/ajax_voting.php';
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url : uri,
|
|
|
|
type : 'POST',
|
|
|
|
data : 'id_post=' + id_post,
|
|
|
|
dataType : 'json',
|
|
|
|
success : function(json, statut) {
|
|
|
|
if(!json.errors) {
|
|
|
|
$(boxes).addClass('active');
|
|
|
|
if (json.already_vote) {
|
|
|
|
if($(boxes).children('.already_vote').length == 0) {
|
|
|
|
$(boxes).append('<span class="already_vote">Déjà voté</span>');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if($(boxes).children('.already_vote').length == 0) {
|
|
|
|
$(boxes).append('<span class="already_vote">Merci</span>');
|
|
|
|
}
|
2015-09-17 16:54:46 +02:00
|
|
|
$('.nb_vote_'+id_post).each(function(index) {
|
|
|
|
$(this).html(json.nb_vote);
|
|
|
|
});
|
|
|
|
|
2015-07-31 11:37:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error : function(resultat, statut, erreur) {
|
|
|
|
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2015-09-17 16:54:46 +02:00
|
|
|
});
|