- Edited
Have simple button that makes ajax call to php page. Doesn't seem like the variables are being passed to the php page. I can hard code the value in the php page and it works. The values re populating to the button as well. What is happening here?
<button class='delete btn btn-danger' id="<?php print $row[id]; ?>" db_table="<?php print $db_table;?>"><i class="fe fe-trash-2"></i></button>
`
$(function () {
$('.delete').click(function(e){
e.preventDefault()
var el = this;
// Delete id
var deleteid = $(this).data('id');
var db_table = $(this).data('db_table');
var $tr = $(this).closest('tr'); //here we hold a reference to the clicked tr which will be later used to delete the row
// Confirm box
bootbox.confirm("Do you really want to delete the tract?", function(result) {
if(result){
// AJAX Request
$.ajax({
url: 'delete_do.php',
type: 'POST',
data: { id: deleteid, db_table: db_table },
success: function(response){
console.log(response);
//on success, hide element user wants to delete.
$tr.find('td').addClass('hilite').fadeOut(2000,function(){
$tr.remove();
});
}
});
}
});
});
});`