我该如何显示动态数据库信息?

时间:2022-10-16 22:22:57

I have a script running that updates my database with live scores of sporting events from an external data source. My question to you guys would be, what is the proper way to display this data so that it constantly updates as the database information does? Does it have to be ajax? Is there a simpler option available?

我有一个运行的脚本,它使用来自外部数据源的体育赛事的实时得分来更新我的数据库。我向你们提出的问题是,显示这些数据的正确方法是什么,以便随着数据库信息的不断更新?它必须是ajax吗?有更简单的选择吗?

Thanks in advance

提前致谢

2 个解决方案

#1


0  

You have two high-level options:

您有两个高级选项:

  1. Poll (ajax) the server every X seconds
  2. 每X秒轮询一次服务器(ajax)

  3. Use an pub/sub-like system (google SocketIO)
  4. 使用pub / sub-like系统(google SocketIO)

#2


0  

The best way that I know is to use a timer (setInterval) that will check your database periodically. John Resig wrote a post about the javascript timers here. That is my suggestion, so hopefully, that can be helpful. :)

我知道的最好的方法是使用定期检查数据库的计时器(setInterval)。 John Resig在这里写了一篇关于javascript计时器的帖子。这是我的建议,希望如此,这可能会有所帮助。 :)

#1


0  

You have two high-level options:

您有两个高级选项:

  1. Poll (ajax) the server every X seconds
  2. 每X秒轮询一次服务器(ajax)

  3. Use an pub/sub-like system (google SocketIO)
  4. 使用pub / sub-like系统(google SocketIO)

#2


0  

The best way that I know is to use a timer (setInterval) that will check your database periodically. John Resig wrote a post about the javascript timers here. That is my suggestion, so hopefully, that can be helpful. :)

我知道的最好的方法是使用定期检查数据库的计时器(setInterval)。 John Resig在这里写了一篇关于javascript计时器的帖子。这是我的建议,希望如此,这可能会有所帮助。 :)