<list.ejs>
$('.delete').click(function(e) {
// Get the selected checkboxes
const selectedCheckboxes = $("input:checkbox:checked");
// Get the data-id attribute of each selected checkbox
const selectedIds = selectedCheckboxes.map(function() {
return $(this).data("id");
}).get();
// Loop through the selected IDs
for (const id of selectedIds) {
// Make an AJAX request for each selected ID
$.ajax({
method: 'DELETE',
url: '/delete',
data: { listnums: id }
}).done(function(result) {
location.reload();
});
}
});
//write button
$('.write').click(function(){
window.location.href = '/jjal'
})
<server.js>
// 삭제요청
app.delete('/delete', function (req, res) {
console.log(req.body);
req.body.listnums = parseInt(req.body.listnums);
// req.body안에 담겨온 게시물번호를 가진 글을 db에서 찾아서 삭제해주세요
db.collection('post').deleteOne(req.body, function (error, result) {
console.log('삭제완료');
});
});
게시물을 선택해서 삭제하는것까진 컨닝하면서 따라왔는데요
쌤이 알려주신것 대로 li사라지는거 따라하는데 도무지 안되네요.
임시 방편이라 생각하고 새로고침을 집어 넣었는데 그것도 안먹고요
더 어떻게 손을 대야 할지 모르겠어요