I have an 'action', which is an object that is the controlling code for
incoming requests. My code looks like this:
loginSubmit: function() {
var self = this,
session = generateCookie();
user.on('loginValid', function(data) {
client.sadd('sessions', session, redis.print);
self.response.setHeader("Set-Cookie",
["session="+session+";Path=/"]);
self.response.writeHead(200);
self.response.end();
});
user.on('loginInvalid', function(data) {
self.statusCode(404);
});
user.login(self.postData.email, self.postData.password);
},
'loginSubmit' is the action, it is executed when a request comes into
/login/submit. Currently only AJAX requests touch loginSubmit, no page
reload.
When I fill the form and hit submit, ajax fires and runs loginSubmit. If I
fill out the form to emit 'loginInvalid', then fill it out again to emit
'loginValid', node throws an error:
http.js:686
throw new Error('Can\'t render headers after they are sent to the
client.'
Why?
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en