I need to delete user from a mySQL row. My "Delete" button works only on the first page, but when I change page it no longer works, as you can see in this image. This is the code I use for delete:
$(document).ready(function() {
$('#large').dataTable({
"sPaginationType": "full_numbers",
"iDisplayLength": 5,
"aoColumnDefs": [{
"bSortable": false,
"aTargets": [-1]
}]
});
$(".lnk").click(function() {
if (confirm("This user will be deleted. Press ok to confirm.")) {
$.ajax({
type: "POST",
url: "deactivate-user.php",
data: {
"user": $(this).attr('id')
},
dataType: 'HTML',
success: function(data) {
if (data == "Error") {
$("#msg").html("Error occured while removing user! Please try after some time.");
$("#msg").addClass("red-box");
$("#msg").css("display", "block");
} else {
$("#msg").html("User has been removed successfully.");
$("#msg").addClass("green-box");
$("#msg").css("display", "block");
$("#main-table").html(data);
}
}
});
}
});
});
<td>
<a href="add-credit.php?user=<?php echo $row['user_id']; ?>" name="credit" class="btn btn-primary credit">Credit</a>
<a id="<?php echo $row['user_id']; ?>" class="btn btn-danger lnk">Delete</a>
</td>
Where is my error?