I have a notification set in laravel and it worked fine, and when I click the notification I want to show a dynamic modal with the notification detail in it, but I couldn't figure how to get each data from the data column
here is my code
$('.detail-btn').click(function() {
const id = $(this).attr('data-id');
console.log(id)
$.ajax({
url: '/admin/notification/' + id,
type: 'GET',
data: {
'id': id,
},
success: function(data) {
console.log(data);
$('#judul').html(data.id);
$('#detail').html(data.data)
}
});
});```
Your "data" variable is a json array. Currently, you're outputting the whole array in your modal. So if you want to display a specific attribute from that array, you can simply change:
$('#detail').html(data.data)
to
$('#detail').html(data.data.name)
Or whichever other attribute you want to display in your modal.