- Joined
- Oct 20, 2014
- Posts
- 1,170
- Solutions
- 2
- Reaction
- 103
- Points
- 498
- Age
- 30
bat ganun pati yun update na link ko ay nadadamaya kapag pinipindot ko yun update nadedelete sya.
<a href= 'commentdelete.php?comment_id=<?php echo $id_comment ?>' class = "btn-delete">Delete</a>
<a href='admincommentdelete.php?id=<?php echo $id_comment ?>' class="btn-delete">Delete</a>
<a href='admincommentdelete.php?id=<?php echo $id_comment ?>' class="btn-update" >Update</a>
ito code ko
$('.btn-delete').on('click', function(e) {
e.preventDefault();
const href = $(this).attr('href');
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: href, // I-update ang URL na ipinapasa sa AJAX request
type: 'POST',
data: {comment_id: <?php echo $id_comment; ?>},
success: function(data) {
if (data = 'success') { // I-update ang comparison operator mula sa "=" papunta sa "==="
Swal.fire(
'Deleted!',
'Your file has been deleted.',
'success'
).then(function() {
location.reload();
});
} else {
Swal.fire(
'Error!',
'An error occurred while deleting the file.',
'error'
);
}
},
});
}
});
});
<a href= 'commentdelete.php?comment_id=<?php echo $id_comment ?>' class = "btn-delete">Delete</a>
<a href='admincommentdelete.php?id=<?php echo $id_comment ?>' class="btn-delete">Delete</a>
<a href='admincommentdelete.php?id=<?php echo $id_comment ?>' class="btn-update" >Update</a>
ito code ko
$('.btn-delete').on('click', function(e) {
e.preventDefault();
const href = $(this).attr('href');
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: href, // I-update ang URL na ipinapasa sa AJAX request
type: 'POST',
data: {comment_id: <?php echo $id_comment; ?>},
success: function(data) {
if (data = 'success') { // I-update ang comparison operator mula sa "=" papunta sa "==="
Swal.fire(
'Deleted!',
'Your file has been deleted.',
'success'
).then(function() {
location.reload();
});
} else {
Swal.fire(
'Error!',
'An error occurred while deleting the file.',
'error'
);
}
},
});
}
});
});