At the bottom of my personal page (1 page website) I have a contact form that sends a message to my database so I can read it later.
The problem is that if I don't redirect to anywhere, the page doesn't reload, which is what I want, but is searching for something and have a loading icon in the tab and eventually disconnects and show the "ECONNRESET" error from Cloud9.
If I do redirect back to /#contact (to the page and then down to the contact section), then it reloads the page, and that's not what I want to happen because of the site's functionality. It has some animations that load right after sending the message and the reload cancels them out and it looks terrible.
How do I make it so that the page doesn't have to reload after sending the message, meaning I don't have to redirect anywhere, but I also don't get the ECONNRESET error?
app.post("/", function (req, res){
// Retrieve form data
var name = req.body.name;
var email = req.body.email;
var subject = req.body.subject;
var message = req.body.message;
var newMessage = {name: name, email: email, subject: subject, message: message};
// Save new message to database
Message.create(newMessage, function (err, sendMessage) {
if (err) {
console.log(err);
} else {
console.log(sendMessage);
}
});
});