How can I pass a dynamic ID obtained from an ajax POST request to a bootstrap modal?
var id = $(this).data('id');
$.ajax({
type: 'POST',
url: "{{ url('/pos/createSubCategory') }}",
data: {id: id},
success: function (data) {
var html = '';
if(!$.trim(data))
{
html = '<div>' + '<h3>' + 'Empty!' + '</h3>' +'</div>';
}
else
{
$.each(data, function () {
html += '<div class="card subCategoryClass" data-target="#subcategory_product_modal" data-toggle="modal" aria-hidden="true" data-dismiss="modal" data-id="@this.id">' + '<p>' + '<button>' + this.name + '</button>' + '</p>' +'</div>';
});
}
},
error: function (data) {
console.log(data);
}
});
Why is data-id="@this.id" not working as expected?