Hallo User barche bissen hilfe mit das bei mir funktioniert mit sweetalert2 es ist eine todo liste und mit sweetalert2 Löschen wenn ich auf dem button drücke passiert nix
PHP
echo'<button title="'.LoadLang('#DELETE#').'" '; ?> <?php echo' id="delete_product" data-id="'.$id.'" class="btn btn-outline-danger btn-icon waves-effect waves-themed p-0 fs-xl mr-2"/><i class="fal fa-trash"></i></button>';
Code
<script>
$(document).ready(function(){
readProducts(); /* it will load products when document loads */
$(document).on('click', '#delete_product', function(e){
var productId = $(this).data('id');
SwalDelete(productId);
e.preventDefault();
});
});
function SwalDelete(productId){
swal({
title: 'Are you sure?',
text: "It will be deleted permanently!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!',
showLoaderOnConfirm: true,
preConfirm: function() {
return new Promise(function(resolve) {
$.ajax({
url: 'functions.php',
type: 'POST',
data: 'deltodo='+productId,
dataType: 'json'
})
.done(function(response){
swal('Deleted!', response.message, response.status);
readProducts();
})
.fail(function(){
swal('Oops...', 'Something went wrong with ajax !', 'error');
});
});
},
allowOutsideClick: false
});
}
</script>
Alles anzeigen
Code
if(isset($_POST['deltodo']) OR isset($_POST['deltodo_x']) OR isset($_POST['deltodo_y'])){
mysqli_query($mysqli, "DELETE FROM ".$prefix."admin_todo WHERE id = '".mysqli_real_escape_string($mysqli, $_POST['deltodo'])."'");
}
was ist hier jetzt falsch kann mir da einer Helfen