从Node / Express发送确认提醒到浏览器,无需重新载入页面

我有一个工作用户身份validation系统的Web应用程序。 当用户更新他们的数据(例如电子邮件地址或密码)时,它会向服务器发送POST请求,从而更新数据库。 我想在成功或错误的时候在现有页面上有一个引导样式块警报。 我可以通过(1)来自服务器的res.send响应和(2) res.send数据的jQuery脚本以及将阻止警告HTML代码插入浏览器的方式来实现这一点吗?

app.post块(通过post请求接收更新后的用户数据)如下所示:

 app.post('/updateuser', function(req, res) { console.log(req.body); [code here to update database] res.send('[code to send to jQuery here]'); 

呈现阻止警报的HTML是:

 <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Success!</strong>User data has been updated. </div> 

如果这是可能的,(a)服务器端res.send或类似和(b)客户端jQuery代码是什么样的?

提前致谢!

你在找什么是连接闪光灯: https : //github.com/jaredhanson/connect-flash

请参阅示例https://github.com/jaredhanson/connect-flash/blob/master/examples/express3/views/index.ejs ,以便在呈现的模板中显示Flash,或者在需要的情况下对消息进行提醒。