(function ($) { $.fn.follow = function () { this.each(function() { $(this).click(function(e) { e.preventDefault(); let $icone = $(this).children('i'); let contenu = $(this).data('content'); let iconeEtatUn = $(this).data('icactif'); let iconeEtatDeux = $(this).data('icinactif'); let chemin = $(this).data('path'); $.ajax({ type: 'POST', url: chemin, data: 'id_film=' + contenu, success: function (data) { console.log(chemin); if ($icone.attr('class') === iconeEtatUn) { $icone.attr('class', iconeEtatDeux); } else { $icone.attr('class', iconeEtatUn); } return; }, complete: function () { } }) }) }) } })(jQuery); (function ($) { $.fn.seen = function () { this.each(function() { $(this).click(function(e) { e.preventDefault(); let $icone = $(this).children('i'); let contenu = $(this).data('content'); let couleurNeutre = $(this).data('neutre'); let couleurVu = $(this).data('vu'); let couleurPasVu = $(this).data('pasvu'); let chemin = $(this).data('path'); $.ajax({ type: 'POST', url: chemin, data: 'id_film=' + contenu, success: function (data) { if ($icone.attr('class') === couleurNeutre) { $icone.attr('class', couleurPasVu); $icone.next().attr('class', couleurNeutre); } else { $icone.attr('class', couleurNeutre); $icone.next().attr('class', couleurVu); } return; }, complete: function () { } }) }) }) } })(jQuery);