使用websocket / socket.io进行部分页面刷新

时间:2014-12-06 00:30:00

标签: socket.io

安装websocket和socket.io以在我的网站中运行IM并进行部分页面刷新。 IM编码并且工作正常。 要进行部分页面刷新,我在服务器中对此进行了编码:

// receive and broadcast log or monitors update
   socket.on('sendUpdate', function(ID)
   {
      io.sockets.emit('getUpdate', ID);
   });

这在客户端:

// send update log or monitors to the server
    function sendUpdate(ID)  // for log and monitors table changes
    {
      socket.emit('sendUpdate', ID); // send it to the server for broadcast to all clients
    };

    // receive log or monitors update
    function getUpdate(ID)
    {
  // how to do this???
};

那么,如何在不刷新整个页面的情况下通过id更新html元素? 任何建议表示赞赏。

0 个答案:

没有答案
相关问题