Stack Overflow 如何在不重新加载页面的情况下显示已添加/编辑的答案消息?
是的,我知道 Ajax 会发生这种情况。所以我在浏览器中打开 Firebug 来检查它,看看是否有任何请求在特定的时间间隔内到来。 但我没有看到 Firebug 中有任何请求。
我们可以在 Firebug 中不显示的情况下执行请求吗? 这背后还有其他想法吗?还是我的概念完全错误?
最佳答案
它似乎正在使用 HTML 5 Web Sockets 。它们基本上在服务器和客户端之间保持开放连接,并且除其他外,还允许客户端定义事件处理程序以在从服务器接收到新数据时处理新数据。
在这里您将找到有关 WebSocket 的一些基本示例和概念:Introducing WebSockets: Bringing sockets to the web 。
The WebSocket specification defines an API establishing "socket" connections between a web browser and a server. In plain words: There is an persistent connection between the client and the server and both parties can start sending data at any time.
还有一个live demo与服务器和客户端 source code可用。
您可能还会发现以下问题很有用:How do real time updates work?
关于javascript - Stack Overflow 如何在不重新加载页面的情况下通知服务器端事件?我在 Firebug 中没有看到任何请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13022873/