i need to pass $(this).data into success func in ajax. here is my code
var product_id = $(this).data("product_id");
var url = "";
$.ajax({
url: url,
type: "POST",
dataType: "json",
data: {
product_id: product_id,
_token: "",
},
success: function (data) {
$(this).addClass("wishlist-comp-saved");
},
});
But $(this).addClass('wishlist-comp-saved'); is not working inside success: function(data) {}
source https://stackoverflow.com/questions/73937470/how-to-pass-this-data-in-ajax-request
No comments:
Post a Comment