If you're ever working with real-time javascript, try Socket.io.

<!DOCTYPE html>
    <title>My App</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Chris Mendez">
    <link rel="shortcut icon" href="/icons/logo-256x256.ico" type="image/vnd.microsoft.icon">
    <link rel="stylesheet" href="/css/plugins/bootstrap.min.css">
    <!--Bootstrap Theme-->
    <link rel="stylesheet" href="/css/themes/bootstrap.min.css">
    <!--Bootstrap Responsive-->
    <link rel="stylesheet" href="/css/plugins/bootstrap-responsive.min.css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <!--Google Web Fonts-->
    <script src="//ajax.googleapis.com/ajax/libs/webfont/1.1.2/webfont.js"></script>
    <!--Twitter Bootstrap-->
    <script src="/js/plugins/bootstrap.min.js"></script>
    <script src="/socket.io/socket.io.js"></script>
      $(document).ready(function() {
      	var socket = io.connect('http://localhost');
	    	//Listen for server handler "news"
	    	trace( "Listening for 'news' event sent from server.js" );
	    	socket.on('news', function ( data ){
		    	trace( "'news' event fired:: " + data )
			    trace( "sending data.hello to 'tmpEvent' w/ message " + data.hello );
			    socket.emit('tmpEvent', { my: data.hello });



* Title: Simple Socket.io
* Desc: A simple socket.io example
* Modified:
* Notes:

var app = require('http').createServer(handler);
var fs = require('fs');
var io = require('socket.io').listen(app);

function handler (req, res) {
  console.log( req, res );
  fs.readFile( __dirname + '/views/index.html', function (err, data)
    if (err) {
      return res.end('Error loading index.html');
    //Write out index.html

//Sockets can be used on top of page rendering
io.sockets.on('connection', function (socket) {
  //Send data to client (index.html)
  socket.emit('news', { hello: 'world' });
  //Receive data from client (index.html)
  socket.on('tmpEvent', function (data) {
    console.log( "'tmpEvent' fired::", data.my );

app.listen( process.env['app_port'] || 8080 );