在网页上实时显示数据 [英] Displaying data in real-time on web page

查看:95
本文介绍了在网页上实时显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定如何用最好的方式表达它,但我正在寻找一种在网页上显示可用数据的方法.示例:在网页上显示 IRC 频道消息,当消息发送到 IRC 频道时,该消息会同时(或以很小的延迟)输出到网页.或者当数据插入数据库时​​,它同时输出到一个网页(再次,或几乎没有延迟).这样的功能是如何实现的?这样的特性可以用 JS/JQuery 实现吗?我假设是的,因为这就是 Mibbit 的工作方式(AJAX).示例或伪代码解释将不胜感激,因为我完全不知道从哪里开始以及我需要什么.

I'm not sure how to phrase it the best way, but what I'm looking for is a way to display data on a web page as it becomes available. Examples: Displaying IRC channel messages on a web page, as a message is sent to an IRC channel, the message is outputted to the web page at the same time (or with very little delay). Or when data is inserted into database, it is outputted to a web page at the same time (again, or with very little delay). How is such a feature implemented? Can such a feature be implemented with JS/JQuery? I'm assuming yes since that's how Mibbit seems to work (AJAX). An example or pseudo-code explanation would be appreciated since I have absolutely no idea where to even start and what I need.

推荐答案

术语是 Comet,它基本上只是一个代码块,用于永远运行并轮询(发送 HTTP 请求)在获取新数据的间隔(如果有),用新数据填充现有区域.

The term is Comet, and it's basically just a block of code setup to run forever and poll (send an HTTP request) at intervals to get new data back, if any, populating an existing area with the new data.

您可以阅读更多相关信息:

You can read more about it:

一个教程(不是最好的代码风格):

A tutorial ( not the best style of code ):

Stackoverflow 问题示例:

Stackoverflow question with an example:

这篇关于在网页上实时显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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