<input type="hidden" value="<?=$comment['id'];?>" name="comId">
<button class="btn btn-sm btn-outline-light" id="remove_<?=$comment['id']?>">Удалить</button>
$(".delete .btn").on('click', function(){
var commentId = this.id.slice(7);
$.post("../delete.php", {id : commentId}, function( serverResponse ){
if( serverResponse === 'ok' ) {
$this.hide();
}
})
})
if($_SERVER[ 'REQUEST_METHOD' ] === 'POST') {
if( is_numeric($_POST['id']) ) {
$commentId = (int)$_POST['id'];
$sqlDel = 'DELETE FROM comments WHERE id = ' . $commentId;
$result = $db->query($sqlDel);
}
}
var commentId = this.id.slice(7);
$.post("../delete.php", {id : commentId}, function( serverResponse ){
if( serverResponse === 'ok' ) {
$this.hide();
}
})
var $this = $(this);
var commentId = this.id.slice(7);
$.post("../delete.php", {id : commentId}, function( serverResponse ){
if( serverResponse === 'ok' ) {
$this.hide();
}
})
<div class="comments_<?= $comment['id']?>">
//тут код
</div>
$('body').on('click', '.btn', function () {
var commentId = this.id.slice(7);
$.ajax({
type: "POST",
url: "/export/post",
data: {
id: commentId
},
success: function (data) {
if(data === 'ok'){
$(".comments_" + commentId).remove();
} else {
console.log('Все плохо');
}
}
})
});
if($_SERVER[ 'REQUEST_METHOD' ] === 'POST') {
if( $id = is_numeric($_POST['id']) ) {
return 'ok';
}
}