itskp-odense/Frontend/Assets/Ajax/deletePost.js

23 lines
614 B
JavaScript

function deletePost(id) {
return $.ajax({
type: 'POST',
url: '../Backend/controller/deletePost.php',
data: {'delete_id':id},
success:function (data) {
Swal.fire(
'Posten er slettet!',
'',
'success'
).then(function() {
$('#table_id').DataTable().row($('#'+id)[0]).remove().draw();
});
},
error:function (data) {
Swal.fire(
'Posten kunne ikke blive slettet',
'',
'error'
)
}
});
}