Stack Overflow 如何在不重新加载页面的情况下通知服务器端事件?我在 Firebug 中看不到任何请求 [英] How does Stack Overflow notify of server-side events without a page reload? I see no request in Firebug

查看:11
本文介绍了Stack Overflow 如何在不重新加载页面的情况下通知服务器端事件?我在 Firebug 中看不到任何请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Stack Overflow 如何在不重新加载页面的情况下显示添加/编辑的答案消息?

How does Stack Overflow show the answer added/edited message without a page reload?

是的,我知道 Ajax 会发生这种情况.所以我在浏览器中打开 Firebug 来检查它,看看是否有任何请求在特定的时间间隔内到来.但是我在 Firebug 中没有看到任何请求.

Yes, I know it will happen with Ajax. So I opened Firebug in a browser to check it, to see whether any requests are coming in a particular interval of time. But I don't see any request coming in Firebug.

我们可以在 Firebug 中不显示的情况下执行请求吗?这背后是否还有其他想法或我的概念完全错误?

Can we perform a request without it showing in Firebug? Are there any other ideas behind this or is my concept totally wrong?

推荐答案

它似乎正在使用 HTML 5 网络套接字.它们基本上保持服务器和客户端之间的开放连接,除此之外,还允许客户端定义事件处理程序来处理从服务器接收到的新数据.

It appears to be using HTML 5 Web Sockets. They basically keep an open connection between the server and the client and, among many other things, allow the client to define event handlers to treat new data when received from the server.

您将在此处找到有关 WebSocket 的一些基本示例和概念:介绍 WebSocket:将套接字带到网络.

Here you'll find some basic examples and concepts about WebSockets: Introducing WebSockets: Bringing sockets to the web.

WebSocket 规范定义了一个 API 建立socket"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.

还有一个 现场演示 与服务器 &客户端源代码可用.

There is also a live demo with server & client source code available.

您可能还会发现以下问题很有用:实时更新如何工作?

You might also find the following question useful: How do real time updates work?

这篇关于Stack Overflow 如何在不重新加载页面的情况下通知服务器端事件?我在 Firebug 中看不到任何请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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