36

I want to debug a REST API and see how it's used from very complex client code. After I identify the AJAX request in the Network tab, how can I go to the code that created it?

enter image description here

Is this impossible?

2
  • Um, how about the XHR log line in the console with the same path? Commented Jan 6, 2015 at 3:30
  • 1
    I don't think you can do this after the XHR request. The only thing you can do is set an XHR breakpoint, which will fire when the XHR is sent.
    – Barmar
    Commented Jan 6, 2015 at 3:39

2 Answers 2

54

See the "Initiator" column in the network tab. It tells you which code initiated the AJAX call. You will also get a tooltip with a full stack trace.

Chrome DevTools Network Tab Initiator Stack Trace

4
  • 1
    Duh. Thanks! I took the liberty to add an even more obvious screenshot. Commented Jan 7, 2015 at 9:49
  • If you use a library like jQuery or Angular to help you make the call, is there a way to see the source code that called the helper functions?
    – Atav32
    Commented Mar 14, 2015 at 1:01
  • 2
    @Atav32: you can just go through the call stack Commented Feb 11, 2016 at 14:24
  • 6
    What if the initiator is "Other"? Commented Aug 14, 2016 at 5:18
13

I don't have 50 reputation to comment so I'm replying to:

If you use a library like jQuery or Angular to help you make the call, is >there a way to see the source code that called the helper functions? – >Atav32 Mar 14 at 1:01

If you want to find "real" method call then add breakpoint in line suggested by "Initiator" column and hit "Step out of current function (Shift+F11)" till you reach code you want to.

Cheers!

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.