Javascript 如何解决“问题”;“重新加载页面循环”;在节点JS中使用post方法时?

Javascript 如何解决“问题”;“重新加载页面循环”;在节点JS中使用post方法时?,javascript,html,node.js,express,post,Javascript,Html,Node.js,Express,Post,给定以下html表单: <form class = "new-date" method = "POST" action = "http://localhost:5600/postDate"> <h3>Owner</h3> <input type ="text" name = "ownerName&quo

给定以下html表单:

<form class = "new-date" method = "POST" action = "http://localhost:5600/postDate">
                <h3>Owner</h3>
                <input type ="text" name = "ownerName" class = "form-element global"  id="owner">
                </select>
                <h3>Pet</h3>
                <input type = "text" name = "petName" class = "form-element global" id = "pet">
                </select>
                <h3>Schedule the date</h3>
                <input type="date" id="birthday" name="birthday" class = "form-element global"  id="date">
                <h3>Description</h3>
                <textarea class = "form-element description-text" placeholder= "What is wrong with your pet?" name ="problem" ></textarea  id="problem"><br>
                <input type="submit" class = "form-element btn" value="Add">
</form>
提交客户端数据并将其发送到我的服务器后,html页面未正确执行重新加载任务:


我是Node JS的新手,你知道未完成的重新加载工作是怎么回事吗?

如果你想让浏览器停止旋转(加载),你需要从服务器发送响应。 例如,使用req.body(echo端点)发送json响应

试试这个

app.post('/postDate', (req, res)=>{
   console.log(req.body.ownerName); //TO CHECK IF IM RECEIVING THE DATA. IT WORKS
   res.json({message: 'OK.'})
});

您需要实际返回路由的响应
app.post('postDate', (req, res) => {
    console.log(req.body.ownerName);
    res.json(req.body);
})
app.post('/postDate', (req, res)=>{
   console.log(req.body.ownerName); //TO CHECK IF IM RECEIVING THE DATA. IT WORKS
   res.json({message: 'OK.'})
});