I have a dataTable with a delete button and I am implementing the sweetalert library. The problem is that clicking on the delete button shows the modal sale of the sweetalerty but does not eliminate.
What could be the problem?
The Code
//============== Las liberías ==============
<script type="" src="plugins/datatables/jquery-1.12.4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css" rel="stylesheet"/>
// ========= El botón ===============
<a href="#" onclick="confirmDelete()" title="Eliminar" class="glyphicon glyphicon-trash btn btn-danger btn-sm"></a>
//======= El javaScript ==============
<script type="text/javascript">
function confirmDelete() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function (isConfirm) {
if (!isConfirm) return;
$.ajax({
url: "ruta-donde-elimino.php",
type: "POST",
data: {
id: 5
},
dataType: "html",
success: function () {
swal("Done!", "It was succesfully deleted!", "success");
},
error: function (xhr, ajaxOptions, thrownError) {
swal("Error deleting!", "Please try again", "error");
}
});
});
}
</script>
// código d ela clase personaData.php
public function del(){
$sql = "delete from ".self::$tablename." where idPersona=$this->idPersona";
Executor::doit($sql);
}
//Código d ela clase persona-action.php
else if (isset($_GET["opt"]) && $_GET["opt"]=="del"){
$persona = new personaData();
$persona->idPersona = $_GET["idPersona"];
$persona->DEL();
header("Location: ./?view=persona&opt=all");
}
The question I have is what the url would be where it says: url: "path-where-delete.php", taking into account the way I delete the records