Thanks asynqronic,
Following code,
*profiles3.js*
module.exports = function(callback){
var spawn = require('child_process').spawn,
ls = spawn('ls', ['-lh', '/usr']);
ls.stdout.on('data', callback);
ls.stderr.on('data', callback);
ls.on('exit', callback);
};
*index.js*
exports.index = function(req, res){
profiles3(function(data){
res.writeHead(200, {
"Content-Type": "text/plain",
"Content-Length": data.length
});
res.end(data, 'uft-8');
});
};
Giving following error,
Express server listening on port 3000
GET / 200 15ms
http.js:687
throw new Error('Can\'t render headers after they are sent to the
client.'
^
Error: Can't render headers after they are sent to the client.
at ServerResponse.OutgoingMessage._renderHeaders (http.js:687:11)
at ServerResponse.res._renderHeaders
(/home/sthapa/Node/stylus5/node_modules/express.io/node_modules/connect/lib/patch.js:69:27)
On Tuesday, February 12, 2013 11:53:43 AM UTC+11, asynqronic wrote:
>
>
>
> On Tuesday, February 12, 2013 5:21:17 AM UTC+7, s thapa wrote:
>>
>> I am thinking of creating a refresh button because auto reload of webpage
>> might froze webpage until data is extracted from server to client and this
>> my annoy users.
>>
>> Any suggestion or sample code are welcome.
>>
>>
>
> In *routes/index.js*
>
> var getData = require('../data.js');
> exports.index = function(req, res){
> getData(function(data) {
> res.writeHead(200, {
> "Content-Type": "text/plain",
> "Content-Length": data.length
> });
> res.end(data, 'utf-8');
> }
> };
>
> In browser:
>
> $("#refresh-button").on("click", function() {
> $("#some-element").load("/some/url");
> }
>
--
--
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
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.