有没有更好的方法来创建异步更新,而无需使用setInterval的?方法来、setInterval

2023-09-10 17:40:49 作者:想念.

我有我的网站的多个部分该检查更新每隔半秒,所以它可以提醒消息的你,等等。不过,我觉得使用$。员额与setInterval的可能是一个有点沉重的网站上。有没有建议对这些任务可以更好的替代方法?

I have multiple parts of my site which check for updates every half a second, so it can alert you of messages, etc. However I feel that using $.post with a setInterval could be a bit heavy on the site. Is there an alternative method that is better recommended for these tasks?

推荐答案

socket.io 将要走的路如果您使用 nodeJS 。否则,结账这个jQuery插件,它优雅降级甚至实施虽然不及COM prehensive为socket.io。

socket.io would be the way to go if you're using nodeJS. Otherwise, checkout this jQuery plugin, it has graceful degradation implemented even though not as comprehensive as socket.io.

 
精彩推荐
图片推荐