This is my jQuery to add/remove from a wish list. I echo added/add to wish list and receive response.
The PHP part is fine, my problem is that the class name is the same for displaying the wish list in all products so innerHtml changes in every product on execution. Each product has a unique id though.
How can I change the wish list icon of only clicked div?
$(document).on('click', '.addingwish', function() {
var product_id = $(this).attr("id");
var email = "<?php echo $_SESSION['username']?>";
$.ajax({
url: "actionadd.php",
method: "POST",
data: {
product_id: product_id,
email: email
},
success: function(data) {
$('.addingwish').html('');
$('.addingwish').html(data);
}
})
});