what am I missing? after "ok" in "are you sure you want to delete", I get nothing. But when i try to alert $id it works. Is it ajax problem?
I have this in my footer.php
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<script>
$(document).ready(function () {
$('.confirm-delete').click(function (e) {
e.preventDefault();
confirmDialog = confirm("Are you sure you want to delete?");
if(confirmDialog)
{
var id = $(this).val();
// alert(id);
$.ajax({
type: "DELETE",
url: "/employee/confirmdelete/"+id,
success: function (response) {
alert("Data deleted successfuly");
}
});
}
});
});
</script>
I have this in my routes.php
$route['employee/confirmdelete/(:any)']['DELETE'] = 'Frontend/EmployeeController/delete/$1';
My delete button
<button type="button" class="btn btn-danger confirm-delete" value="<?= $row->id; ?> ">Confirm Delete</button>
My delete function in controller
public function delete($id)
{
$this->load->model('EmployeeModel');
$this->EmployeeModel->deleteEmployee($id);
redirect(base_url('employee'));
}
my model delete function
public function deleteEmployee($id)
{
return $this->db->delete('employee', ['id' => $id]);
}"