看看Socket.IO http://socket.io/#how-to-use
当服务器决定广播更改用途时:
io.sockets.emit('update-msg', { data: 'this is the data'});在客户端上,首先连接socket.io,然后等待“ update-msg”事件并更新您的dom:
var socket = io.connect('http://localhost');socket.on('update-msg', function (msg) { console.log(msg); $('#mydiv').html(msg.data)});


