隐藏/不可见的 Ajax 请求?

Hidden/invisible Ajax request?(隐藏/不可见的 Ajax 请求?)

本文介绍了隐藏/不可见的 Ajax 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以编写和创建无法被 Firefox 中的 Firebug 插件捕获的 JavaScript Ajax 请求?

Is it possible to write and create a JavaScript Ajax request witch cannot be catched by the Firebug plugin in Firefox?

我问这个是因为我可以在 Facebook 上看到没有 Ajax 请求正在进行,但是当我从另一个帐户发送消息时,顶部的消息框会添加1 条未读消息"指示器...这怎么可能实现?

I'm asking this because I can see on Facebook that there are no Ajax request going on, but still when I sent a message from another Account, the message box on the top will add the "1 unread message" indicator... How's even this possible to achive?

谢谢.

推荐答案

Firebug 将标准"AJAX 请求记录到控制台面板;这些是使用 ActiveX/XHR 发起的请求.

Firebug logs "standard" AJAX requests to the Console panel; these are requests initiated using ActiveX/XHR.

不过,其他类型的请求也在发生 - CSS 加载、图像、javascript 等.这些请求记录在 Firebug 的网络面板中.另请注意,在控制台中记录的请求出现在网络中.

Other types of requests are happening, though - CSS loading, images, javascript, etc. These requests are logged in Firebug's Net panel. Note also that requests logged in Console also appear in Net.

JSONP 是 AJAX 的一种跨域方法,其中将 <script> 标签添加到页面.当请求完成时,脚本标签的加载内容被解析为 JSON.这样做的原因是您欺骗"您的浏览器将请求视为对 javascript 资源的请求而不是 AJAX 请求,从而绕过跨浏览器的安全限制.

JSONP is a cross-domain method of AJAX in which a <script> tag is added to the page. When the request completes, the loaded contents of the script tag are parsed as JSON. The reason this works is that you are "tricking" your browser into treating the request as a request for a javascript resource rather than an AJAX request, thus skirting cross-browser security restrictions.

综上所述,JSONP 请求(以及所有其他类型的请求,在 这里 以及所有 <iframe> 请求)都记录在网络面板上,而不是控制台面板上.这不是错误或问题.理解 JSONP 的工作方式,请求只会出现在网络中是合乎逻辑的.

Putting this all together, JSONP requests (as well as all other types of requests, listed here as well as all <iframe> requests) are logged on the Net panel rather than in the Console panel. This isn't a bug or a problem; understanding the way JSONP works it is logical that the request would only appear in Net.

这篇关于隐藏/不可见的 Ajax 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:隐藏/不可见的 Ajax 请求?

基础教程推荐