How does Stack Overflow show the answer added/edited message without a page reload?
Stack Overflow如何在没有页面重载的情况下显示添加/编辑的消息?
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.
是的,我知道这将发生在Ajax上。因此,我在浏览器中打开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?
我们可以在不显示Firebug的情况下执行请求吗?这背后是否有其他的想法,或者我的观点完全错误?
2 个解决方案
#1
12
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.
它似乎在使用HTML 5 Web Sockets。它们基本上保持服务器和客户端之间的开放连接,并允许客户端定义事件处理程序来处理从服务器接收到的新数据。
Here you'll find some basic examples and concepts about WebSockets: Introducing WebSockets: Bringing sockets to the web.
在这里,您将看到一些关于WebSockets的基本例子和概念:介绍WebSockets:把sockets带到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.
WebSocket规范定义了在web浏览器和服务器之间建立“socket”连接的API。简单地说,客户机和服务器之间有一个持久连接,双方可以随时开始发送数据。
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?
您可能还会发现以下问题很有用:实时更新是如何工作的?
#2
3
To add to Xavi's answer, if you want to get started with web sockets without having to understand all the internals, you might try out Pusher, a library for multiple platforms (including PHP) that makes push notifications on the web very straightforward.
为了补充Xavi的答案,如果您想开始使用web套接字,而不需要了解所有的内部结构,您可以尝试Pusher,一个用于多个平台(包括PHP)的库,它使web上的推送通知非常简单。
I do not work for Pusher; it's just a product I've found very useful in the past. I've always used the free version for small personal projects, though I would probably pay if I ever used it on a larger application.
我不为推手工作;它只是我过去发现非常有用的产品。我一直使用免费版的小型个人项目,但如果我在更大的应用程序上使用它,我可能会付费。
#1
12
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.
它似乎在使用HTML 5 Web Sockets。它们基本上保持服务器和客户端之间的开放连接,并允许客户端定义事件处理程序来处理从服务器接收到的新数据。
Here you'll find some basic examples and concepts about WebSockets: Introducing WebSockets: Bringing sockets to the web.
在这里,您将看到一些关于WebSockets的基本例子和概念:介绍WebSockets:把sockets带到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.
WebSocket规范定义了在web浏览器和服务器之间建立“socket”连接的API。简单地说,客户机和服务器之间有一个持久连接,双方可以随时开始发送数据。
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?
您可能还会发现以下问题很有用:实时更新是如何工作的?
#2
3
To add to Xavi's answer, if you want to get started with web sockets without having to understand all the internals, you might try out Pusher, a library for multiple platforms (including PHP) that makes push notifications on the web very straightforward.
为了补充Xavi的答案,如果您想开始使用web套接字,而不需要了解所有的内部结构,您可以尝试Pusher,一个用于多个平台(包括PHP)的库,它使web上的推送通知非常简单。
I do not work for Pusher; it's just a product I've found very useful in the past. I've always used the free version for small personal projects, though I would probably pay if I ever used it on a larger application.
我不为推手工作;它只是我过去发现非常有用的产品。我一直使用免费版的小型个人项目,但如果我在更大的应用程序上使用它,我可能会付费。