GMail Chat 如何能够在没有客户端交互的情况下发出 AJAX 请求?

2023-11-28前端开发问题
2

本文介绍了GMail Chat 如何能够在没有客户端交互的情况下发出 AJAX 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

所有 HTTP 响应都需要客户端启动它们,即使是使用 AJAX 做出的响应.但是 GMail 的聊天功能能够接收来自其他用户的消息,即使我只是坐在舒适的电脑椅上观看但不与浏览器交互.他们是怎么做到的?

All HTTP responses require the client to initiate them, even those made using AJAX. But GMail's chat feature is able to receive messages from other users, even when I'm just sitting in my comfy computer chair watching but not interacting with the browser. How did they do it?

推荐答案

这种技术被称为彗星",也被称为服务器推送"、反向ajax"等.

That tech is known as "comet", but also as "server push", "reverse ajax", etc.

这是关于将数据从服务器推送到浏览器,保持 http 连接处于活动状态.在 维基百科文章 (英文版).

It's about pushing data from the server to the browser, keeping an http connection alive. Find more info on it on the wikipedia article (English version).

这里还有一个 相当不错的演示文稿,来自 DWR 的 Joe Walker,他在哪里谈论彗星.

Also here's a pretty good presentation with Joe Walker from DWR, where he talks about comet.

这篇关于GMail Chat 如何能够在没有客户端交互的情况下发出 AJAX 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

ajax请求获取json数据并处理的实例代码
ajax请求获取json数据并处理的实例代码 $.ajax({ type: 'GET', url: 'https://localhost:44369/UserInfo/EditUserJson',//请求数据 data: json,//传递数据 //dataType:'json/text',//预计服务器返回的类型 timeout: 3000,//请求超时的时间 //回调函数传参 suc...
2024-11-22 前端开发问题
215

layui 单选框、复选框、下拉菜单不显示问题如何解决?
1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
2024-11-09 前端开发问题
313

Rails 3.1 ajax:成功处理
Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)...
2024-04-20 前端开发问题
11

CoffeeScript 总是以匿名函数返回
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)...
2024-04-20 前端开发问题
13

getFullYear 在一年的第一天返回前一年
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)...
2024-04-20 前端开发问题
6

如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?
How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社...
2024-04-20 前端开发问题
6