确定发出 HTTP 请求的 JavaScript 函数
我正在尝试调试一些特别令人讨厌的 Javascript。具体来说,我试图确定哪些函数正在发出某些 http 请求。由于 .js 文件的剪切大小和质量普遍较差,因此不像手动查找文件那么容易。
我对 Fiddler 和 Firebug 有点了解,这是这些应用程序中内置的功能吗?如果可能的话,是否有更好的方法来做到这一点?
Ive got some particularly nasty Javascript I am trying to debug. Specifically, I am trying to determine what functions are making certain http requests. Due to the shear size of the .js file and the generally poor quality, it is not as easy as hunting through the file manually.
I am vaguely experienced with Fiddler and Firebug, is this a capability built into those applications? Is there a better way to do this, if it is even possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无论文件的大小或质量如何,您都应该能够 grep 查找关键字“XMLHttpRequest”并在使用它的地方设置断点。
您还可以在页面加载时,在调用其他任何内容之前,对 XMLHttpRequest 全局进行猴子补丁:
或者更复杂的东西。
Regardless of size or quality of the file, you should be able to grep for the keyword 'XMLHttpRequest' and set breakpoints where it's used.
You could also, on page load, before anything else is called, monkeypatch the XMLHttpRequest global:
Or something more sophisticated.
在 Google Chrome 的开发版本中,您现在可以破解任何 XHR 上的代码。 (扳手>工具>开发者工具)
In the development version of Google Chrome you now have the ability to break the code on any XHR that is made. (wrench > tools > developer tools)
是的!在 Firebug 中,转到顶部菜单上的“Net”,然后从下面的菜单中选择“XHR”,以查看访问该页面期间进行的所有 ajax 调用。这将显示大量信息,例如调用持续时间和请求/响应标头。
Yup! In firebug go to 'Net' on the top menu and choose 'XHR' from the menu right below to see all ajax calls being made during a visit to the page. This will display a wealth of information like the duration of the calls, and request / response headers.