Answer the question
In order to leave comments, you need to log in
How to update information on a page in nodejs?
Rendering the main page:
main.get('/', function(req, res) {
res.render('main', data);
res.end();
}
main.get('/newdata', function(req, res) {
res.render('main', data);
res.end();
}
Error: Can't set headers after they are sent.
Answer the question
In order to leave comments, you need to log in
I will disappoint you, but this problem cannot be solved by simple means. The render result is already sent to the client and you can't change it (although it's strange that such an error appears, these are 2 different answers). There are two solutions:
1) Look towards Meteor ;
2) Use websocket .
2nd I will explain: you have updated data (let's say data), you send a message to the client that there is updated data with a rendered result and using jQuery (for example) update the data on the page.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question