I have been struggling with this for awhile and just cant get it figured out. My delete button is sending the server a GET /delete? and returning a 304
This is also my first post here and i di try and figure this out for a few hours first... but i am new to programming in general and would appreciate any guides or help you can offer - thanks!
I have 3 files at play here: addpost.js, addpost.ejs, and app.js
This is in addpost.js
router.delete('/delete', function (req, res){ Comment.findById(req._id, function (err, Comment){ console.log('DELETE removing ID: ' + comments._id) res.format({ html: function(){ res.redirect('/'); }, json: function(){ res.json({message: 'deleted', title : comments}); } }); }); });
This is in app.js
app.use('/delete', addpost)
This is in addpost.ejs
<div class ="form">
<form method="delete" action="/delete">
<div class="delete">
<button class="btn btn-raised btn-warning" type="submit">Delete</Button>
</form>
</div>
If the form is sending the GET request, then it probably means it doesnt support DELETE method. I think its supported since html5, but ... maybe it has partial support. Use POST instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.