14

I have MVC view, in that tens of javascript files are included. there are some ajax requests initiated from the page. I would like to know from which particular js file the call was initiated.

I spent some time exploring Firefox addons - Firebug and HttpFox. Both are showing the http request, header , cookies and other hell lot of information, but nothing about the source where the ajax request was initiated.

Brainchild
  • 1,814
  • 5
  • 27
  • 52

2 Answers2

12

I've been finding some of Chromes more recent debugging features very useful. Bring up the inspector(Ctrl+Shift+I) and switch to the Network tab before launching your application or performing the actions in question. Each http request will show the origin of the request in the Initiator column. If javascript initiated the request, it will show you the filename and line number with a clickable link to go straight to it.

DannyMeister
  • 1,281
  • 1
  • 12
  • 21
  • 1
    Thanks for the help. unfortunately as we are using Jquery for ajax calls all the calls are shown from jquery file. – Brainchild Apr 30 '12 at 20:36
  • 1
    At least at this point it has quickly identified for you a good place in the jquery library file to throw a breakpoint so that you can look at the call stack in your debugger, as Musa suggests. – DannyMeister Apr 30 '12 at 21:30
4

Another very good option in chrome developer tools is XHR Breakpoint. Press F12, Select the sources tab and on the right had side under XHR Breakpoint add a new conditional breakpoint condition by specifying the text you expect to find in the URL on which the ajax call is being made. It will stop on any ajax call which contains the text specified in the URL. You can give it a try on this URL (look for the heading Breakpoints on XHR)

DotNetJourneyMen
  • 129
  • 1
  • 2
  • 8