0
내 DB에 컬렉션을 삭제하려면 다음 코드를 사용하고 삭제 아약스에 다시 성공 호출을 사용하는 방법 :[Node.js를]
클라이언트 :
$('.destroy').click(function() {
if(confirm("Are u sure?")) {
$.ajax({
type: 'DELETE',
url: '/destroy/' + dataId,
success: function(response) {
console.log('Success');
}
});
} else {
alert('Cancelled');
}
});
서버 :
내가 파괴 버튼을 클릭하고 페이지를 다시로드하면app.get('/destroy/:id', function(req, res) {
var id = req.param("id");
MyModel.remove({
_id: id
}, function(err){
if (err) {
console.log(err)
}
else {
console.log('Collection removed!');
}
});
});
는 컬렉션이 없을 것, 작업이지만, 함께 성공 콜백 함수 : [console.log('Success');]
는 ..
성공 함수를 실행하려면 서버에서 클라이언트로 콜백을 보내야합니다 ???
console.log ('성공')을 만드는 방법; 운영??
감사합니다.
감사합니다. 8 분 안에 당신의 대답을 받아 들일 것입니다! :) –
@ mr.BearAndBeer - 여러분을 환영합니다! – adeneo