doukuilian8365 2014-05-26 09:43
浏览 71

替代通知系统比Javascript setInterval与ajax

I built a notification system that checks whether there are new notifications every 10 seconds using the setInverval javascript function, that sends ajax request and returns a json with the notifications.

I would like to hear alternative ways to do that, that doesn't have to be timed.

Is a while loop & a worker thread better? Since I'm working with PHP, how do I not overload the server with too many requests?

What are the security risks I am facing with my system, and with the system you'd like to suggest.

  • 写回答

1条回答 默认 最新

  • douzhuochao4027 2014-05-26 09:50
    关注

    If you're not satisfied with your current mechanism, look into the cluster of various mechanisms collectively called "comet" and/or web sockets depending on the browser profiles you have to support (IE8 and 9 don't have web sockets, for instance). There are several libraries out there to help you with this, such as socket.io.

    I don't think the security profile changes either way, but that would probably be a separate question in any case.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何实现从tello无人机上获取视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决