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
| $("input[data-xxx=jaime]").on('click', function() {
if($(this).attr('name') === 'like') {
jaime = $(this).parent('div').children("input[name=jaime]").val();
$(this).parent('div').children("input[name=jaime]").attr('name', 'jaimepas');
id = $("input[name=id]").val();
$(this).css('background', 'url(coeur_on.png) transparent no-repeat center').attr('name', 'dislike');
alert(id);
$.ajax({
url : 'acceuil.class.php',
type: 'post',
data : 'jaime=' + jaime + '&id='+ id ,
dataType : 'text',
success : function (text, statut){
$('#'+jaime+'jaime').text(text);
},
error : function(resultat, statut, erreur){
},
complete : function(resultat, statut){
}
});
} else {
$("input[name=dislike]").on('click', function() {
jaimepas = $(this).parent('div').children("input[name=jaimepas]").val();
$(this).parent('div').children("input[name=jaimepas]").attr('name', 'jaime');
id = $("input[name=id]").val();
$(this).css('background', 'url(coeur_off.png) transparent no-repeat center').attr('name', 'like');
$.ajax({
url : 'acceuil.class.php',
type: 'post',
data : 'jaimepas=' + jaimepas + '&id='+ id ,
dataType : 'text',
success : function (text, statut){
$('#'+jaimepas+'jaime').text(text);
},
error : function(resultat, statut, erreur){
},
complete : function(resultat, statut){
}
});
});
}
}); |