有没有更好的方法来创建异步更新,而无需使用setInterval的? [英] Is there a better way to create asynchronous updates without using setInterval?

查看:113
本文介绍了有没有更好的方法来创建异步更新,而无需使用setInterval的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的网站的多个部分该检查更新每隔半秒,所以它可以提醒消息的你,等等。不过,我觉得使用$。员额与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.

这篇关于有没有更好的方法来创建异步更新,而无需使用setInterval的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆