<small id='ERcDo'></small><noframes id='ERcDo'>

  • <legend id='ERcDo'><style id='ERcDo'><dir id='ERcDo'><q id='ERcDo'></q></dir></style></legend>
      <bdo id='ERcDo'></bdo><ul id='ERcDo'></ul>

      <i id='ERcDo'><tr id='ERcDo'><dt id='ERcDo'><q id='ERcDo'><span id='ERcDo'><b id='ERcDo'><form id='ERcDo'><ins id='ERcDo'></ins><ul id='ERcDo'></ul><sub id='ERcDo'></sub></form><legend id='ERcDo'></legend><bdo id='ERcDo'><pre id='ERcDo'><center id='ERcDo'></center></pre></bdo></b><th id='ERcDo'></th></span></q></dt></tr></i><div id='ERcDo'><tfoot id='ERcDo'></tfoot><dl id='ERcDo'><fieldset id='ERcDo'></fieldset></dl></div>
        <tfoot id='ERcDo'></tfoot>
      1. 如何检查 HTTP 请求是否在浏览器中打开?

        时间:2023-05-15
        <legend id='r2ws7'><style id='r2ws7'><dir id='r2ws7'><q id='r2ws7'></q></dir></style></legend>
                <tbody id='r2ws7'></tbody>
            1. <small id='r2ws7'></small><noframes id='r2ws7'>

              <i id='r2ws7'><tr id='r2ws7'><dt id='r2ws7'><q id='r2ws7'><span id='r2ws7'><b id='r2ws7'><form id='r2ws7'><ins id='r2ws7'></ins><ul id='r2ws7'></ul><sub id='r2ws7'></sub></form><legend id='r2ws7'></legend><bdo id='r2ws7'><pre id='r2ws7'><center id='r2ws7'></center></pre></bdo></b><th id='r2ws7'></th></span></q></dt></tr></i><div id='r2ws7'><tfoot id='r2ws7'></tfoot><dl id='r2ws7'><fieldset id='r2ws7'></fieldset></dl></div>
              <tfoot id='r2ws7'></tfoot>

                <bdo id='r2ws7'></bdo><ul id='r2ws7'></ul>

                  本文介绍了如何检查 HTTP 请求是否在浏览器中打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  有没有一种简单的方法可以检测 XMLHttpRequest 在浏览器窗口中是否处于活动状态?或者有多少是活跃的?IE.有没有办法检测我的浏览器窗口中是否有任何 AJAX 调用处于活动状态?

                  Is there an easy way to detect if an XMLHttpRequest is active in the browser window? Or how many are active? ie. Is there a way to detect if there are any AJAX calls active in my browser window?

                  问题扩展: 使用 javascript 有没有办法可以查看是否打开了任何 XMLHttpRequests?比如window.XMLisActive()"之类的?

                  Extension of question: Using javascript is there a way I can see if any XMLHttpRequests are open? Such as "window.XMLisActive()" or something like that?

                  解决方案:最终为 XMLHttpRequest 编写了一个包装器:gist here

                  Solution: Ended up writing a wrapper for XMLHttpRequest: gist here

                  推荐答案

                  除非您为 XmlHttpRequest 编写一个包装器(或对其进行猴子补丁),否则无法检测来自 JS 的打开连接跟踪打开的连接.

                  There is not a way to detect an open connection from JS unless you write a wrapper for XmlHttpRequest (or monkey patch it) that keeps track of opened connections.

                  这里是kidcapital的猴子补丁,不确定是否完美,但这是一个好的开始

                  Here's kidcapital's monkey patch, not sure if it's perfect, but it's a good start

                    (function() {
                      var oldOpen = XMLHttpRequest.prototype.open;
                      window.openHTTPs = 0;
                      XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
                        window.openHTTPs++;
                        this.addEventListener("readystatechange", function() {
                            if(this.readyState == 4) {
                              window.openHTTPs--;
                            }
                          }, false);
                        oldOpen.call(this, method, url, async, user, pass);
                      }
                    })();
                  

                  注意

                  这不处理 fetch 或 websockets,但你可以在这些情况下做类似的事情.

                  This does not handle fetch or websockets but you could do something similar in those cases.

                  这篇关于如何检查 HTTP 请求是否在浏览器中打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Chrome 中 JQuery 停止和挂起的 ajax 请求 下一篇:XMLHttpRequest 浏览器支持

                  相关文章

                • <small id='YEDEm'></small><noframes id='YEDEm'>

                    <bdo id='YEDEm'></bdo><ul id='YEDEm'></ul>
                  <legend id='YEDEm'><style id='YEDEm'><dir id='YEDEm'><q id='YEDEm'></q></dir></style></legend>

                  1. <tfoot id='YEDEm'></tfoot>
                    1. <i id='YEDEm'><tr id='YEDEm'><dt id='YEDEm'><q id='YEDEm'><span id='YEDEm'><b id='YEDEm'><form id='YEDEm'><ins id='YEDEm'></ins><ul id='YEDEm'></ul><sub id='YEDEm'></sub></form><legend id='YEDEm'></legend><bdo id='YEDEm'><pre id='YEDEm'><center id='YEDEm'></center></pre></bdo></b><th id='YEDEm'></th></span></q></dt></tr></i><div id='YEDEm'><tfoot id='YEDEm'></tfoot><dl id='YEDEm'><fieldset id='YEDEm'></fieldset></dl></div>