Can firebug detect ajax operations that are in progress?
The firebug console has various panels that can keep track of a lot of information. The net panel keeps track of almost all network traffic and reports various pieces of information on that traffic, e.g. headers, latency, request parameters, etc. What I would like to do is access all this information programatically from the javascript panel because I have a script that needs to know if there is a request in progress. I haven't found any documentation on how the various panels interoperate or if they are even aware of each other. I need to make the script as generic as possible so tying 开发者_如何学JAVAthe script to the code on the page is not desirable because the script would not operate on other pages because of minor quirks like function names not being the same.
What you're asking for is to gain access to Firebug's internal functionality, which can only be done if they expose an API. As far as I know, they don't expose an API to javascript, other than the familiar console
object.
What they do have however, is an API for firefox plugin development. So you can create a firefox plugin that then either extends the Net panel of firebug to do what you want, or exposes another javascript object called console.net
or something like that.
Here is a good tutorial (well, part of a tutorial series) that explains specifically how to listen to events in the net panel: http://www.softwareishard.com/blog/firebug-tutorial/extending-firebug-net-panel-listener-part-viii/
Check out firebug plugin NetExport
Edit: Here is the source code:
Also this source code may interest you tracingconsole
Well as far as I know, the only way to really "know" about in-flight XMLHttpRequests is to explicitly "remember" them in the code. It's like timeouts and interval timers - if your code doesn't hang on to a handle, it's lost.
If the pages in question do everything via jQuery or some other framework, then it might be possible to worm into that code and leverage whatever's done to track ajax work, but exactly how you'd do that would depend on the framework.
It might help your progress if you were to explain more about what it is you want to achieve with this technique. In other words, while what you asked about directly may not be possible, it might be possible to find another way to do whatever it is you want.
精彩评论