In general, I spent half a day and did not solve the problem! The form is created dynamically.
public / js / main.js
var answerOrQuestion = ''; answerOrQuestion += '<form method="post" action="" id="answerOrQuestionContainer"><div class="rasporka"></div><hr>'; answerOrQuestion += '<p><input type="text" name="Name" placeholder="Name" /></p>'; answerOrQuestion += '<p><textarea name="answer" placeholder="Your answer"></textarea></p>'; answerOrQuestion += '<input type="submit" value="Post Your Answer" />'; answerOrQuestion += '</form>'; $('.container').append(answerOrQuestion); Form processing:
$('.container').on("submit", '#answerOrQuestionContainer', function(event) { event.preventDefault(); $.post("/question/saveQuestion", function (result) {}); }); app.js
var question = require('./routes/question'); app.get('/question', question); routes / question.js
router.post('/saveQuestion', function(req, res) { /* что-то делаем */ }); And we get 404 when trying to send a request! Does anyone have any suggestions ?! Thank you in advance