https://stackoverflow.com/questions/41960353/onclick-not-working-after-adding-ajax-in-jquery
function deleteRow() {
$(document).on('click', '.btn-danger', function() { // load new appended elements to click evt
var id = $(this).attr("id");
console.log('delete ID: ' + id ) ;
if (confirm("Are you sure you want to delete this Guest?")) {
$.ajax({
url: "delete.php",
dataType: 'html',
type: "POST",
data: {id:id},
cache: false,
})
.done(function (response) {
$('#result').show() ;
$("#result").html("Guest Deleted");
$('.delete_user' + id ).fadeOut('slow');
setTimeout(function(){
$("#result").fadeOut("slow");
},4000)
})
.fail(function (jqXHR, textStatus, errorThrown) {
// show error
console.log("Request Failed: " + textStatus, errorThrown) ;
$("#result").html('Error found trying to submit the form: ' + jqXHR );
});
} else {
return false;
}
});
}