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

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

    <tfoot id='Iu3jb'></tfoot>

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

      3. 在 Chrome 中的 XHR 中设置断点

        时间:2023-05-15

          <bdo id='8a0XA'></bdo><ul id='8a0XA'></ul>

            <tfoot id='8a0XA'></tfoot>
              1. <small id='8a0XA'></small><noframes id='8a0XA'>

                  <tbody id='8a0XA'></tbody>
              2. <i id='8a0XA'><tr id='8a0XA'><dt id='8a0XA'><q id='8a0XA'><span id='8a0XA'><b id='8a0XA'><form id='8a0XA'><ins id='8a0XA'></ins><ul id='8a0XA'></ul><sub id='8a0XA'></sub></form><legend id='8a0XA'></legend><bdo id='8a0XA'><pre id='8a0XA'><center id='8a0XA'></center></pre></bdo></b><th id='8a0XA'></th></span></q></dt></tr></i><div id='8a0XA'><tfoot id='8a0XA'></tfoot><dl id='8a0XA'><fieldset id='8a0XA'></fieldset></dl></div>
                <legend id='8a0XA'><style id='8a0XA'><dir id='8a0XA'><q id='8a0XA'></q></dir></style></legend>

                  本文介绍了在 Chrome 中的 XHR 中设置断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个页面在提交表单时发送 XHR 请求,我想让 Chrome 在收到响应时中断.实现这一点的最佳方法似乎是 Chrome 有一个我可以调用的 javascript 函数来中断执行,但到目前为止我一直找不到类似的东西.还有其他解决方案吗?

                  I have a page that sends an XHR request when a form is submitted and I would like to get Chrome to break when it receives a response. It seems like the best way to accomplish this would be if Chrome has a javascript function that I can call that breaks execution but I've been unable to find anything like that so far. Is there another solution?

                  编辑:

                  我实际上没有为请求定义回调,所以我不能那样设置断点.请求正在使用这行 jquery 代码发送:

                  I don't actually have a callback defined for the request so I can't set a breakpoint that way. The request is being sent with this line of jquery code:

                  $.post(this.action, $(this).serialize(), null, "script");
                  

                  其中 this 是一个表单元素.null 参数是您通常定义回调的地方,但使用 "script" 参数,服务器返回原始 javascript 然后直接执行,所以它似乎是唯一的中断和单步执行代码的方法是使用 debugger; 语句.这可行,但是在单步执行代码时,您实际上无法看到您所在的行,因此有点尴尬.我怀疑这是 Chrome 调试工具的限制.

                  where this is a form element. The null argument is where you would usually define a callback but with the "script" argument, raw javascript is returned by the server and then directly executed, so it seems the only way to break and step through the code is with the debugger; statement. This works, but when stepping through the code you can't actually see which line you are on so its a little awkward. I suspect that this is a limitation of Chrome's debugging tools.

                  推荐答案

                  下拉 chrome 控制台 (ctrl+shift+j) 并键入以下任意一个:

                  drop down the chrome console (ctrl+shift+j) and type any of these:

                  只需重写jquery ajax:

                  Just rewrite the jquery ajax:

                  var prevajax = jQuery.ajax;
                  jQuery.ajax = function () { debugger; return prevajax.apply(jQuery, arguments); };
                  

                  或者如果你没有使用 jQuery,重写 xhr 类:

                  or if you are not using jQuery, rewrite the xhr class:

                  var prevxhr = XMLHttpRequest;
                  XMLHttpRequest = function (){debugger; prevxhr.apply(this, arguments);};
                  

                  中断后,只需按shift+f11,直到找到发起ajax请求的方法.

                  After it breaks, just press shift+f11 until you find the method which initiates the ajax request.

                  这篇关于在 Chrome 中的 XHR 中设置断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:jQuery AJAX 在窗口卸载时触发错误回调 - 如何过滤掉卸载并只捕获真正的错误? 下一篇:Google Maps/Places 'autocomplete' API 可以通过 AJAX 使用吗?

                  相关文章

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

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

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