$.ajax({
method: 'get',
url: '{{route('customer.social_links.index')}}',
success: function (data) {
$.each(data, function (i, order) {
$links.append(
'<div class="shadow p-2 m-1 row"><div class="col-6">'
+ '<b>' + order.account + '</b><br><span>' + order.account_name +
'</span>' +
'</div>' +
'<div class="col-6">' +
'<div class="row">' +
'<input type="hidden" value=' + order.id + 'id="delete-data">' +
'<button type="button" class="deleteSocialLink" >' +
' <i class="fa fa-trash fa-4x" onclick="deleteData();"></i></button> </div>' +
'</div>');
});
},
error: function () {
alert('error occurred');
}
});
I've sent an ajax request to the serve the data is received perfectly. After that I'm calling the following function. but it says deleteData() is not defined.
function deleteData() {
$.ajax({
method: 'post',
url: "{{route('customer.unlink')}}",
data: {
"_token": "{{csrf_token()}}",
"id": $("#delete-data").val(),
},
success: function (data) {
console.log(data);
}
});
}
It gives the following result but when i click on any divs only the first one is clicked. Recult shown here