How can I figure out where a request is made in a javascript application?
I’m debugging a large application which generates an incorrect HTTP request somewhere. I believe I haven’t configured something properly with the API generating the request (Google Maps). If I could figure out where the request is made, then I could trace back to the construction of the URL and see where I need to set the right parameters.
Is it possible (in Safari/Chrome/Firefox with Firebug or anything else) to break at the point any request is made?
In Firebug there’s a new feature that lets you break when an
XmlHttpRequestis made. You can then examine the stack to see who the caller is:Break-on-XHR:
In the case the request is made by way of regular dom manipulation (like an image tag being inserted), you could break when the DOM is changed:
The LiveHttpHeaders add-on could also be used to watch all HTTP requests and then you could grep the source for some identifiers used.
A couple of other ways to set a breakpoint in Firebug:
insert this break statement into the code:
open the script tab and select the line you want to break at