AJAX: getting javascript ajax call function

Is there a way to find out (with some developer tools: chrome, Firefox, Opera, etc.) what is the last function that calls the AJAX call?

It would be interesting to debug web applications.

thanks

+6
source share
5 answers

Here's how I do it in Google Chrome:

  • Download web app
  • Press F12 to open Chrome Developer Tools.
  • Click the Profiles tab.
  • Select Collect JavaScript Processor Profile
  • Click Start
  • Use your web application as usual.
  • When you are finished using the web application, go back to the Developer Tools and click Stop

As a result, you will get a profile similar to the profile shown in the figure below. This profile shows every JavaScript call made during profile capture, including any AJAX calls, and also where the call was made in your code (which function β€œchallenged”).

enter image description here

As you can see in this screenshot, I had an AJAX call from my script (dash.js, line 51) from a function called doOnSelectDate () , which itself is called from a function called getDailySummary () (defined in the line 60).

enter image description here

+7
source

Take a look at console.trace() , it will give you the stack information you are after.

enter image description here

+3
source

Here's how to do it in Firefox and Chrome. For both, I used the jQuery W3Schools example here so you can follow exactly.

For Firefox.

Fire up an event that triggers AJAX. Open the Firebug console and click the source link.

If you wrote your own low-level AJAX function, that will be enough and lead you to your source. But since most people will use jQuery to minimize it, you will get a jquery.min.js link that doesn't help.

Console with AJAX and link to source

If you use jquery.min.js, click on the link in the console and set a breakpoint in the line specified in the link (line 6).

Placing the breakpoint

Now start AJAX again and it will stop at the breakpoint. Click on the stack tab and your call should be somewhere there. Click on it and it will take you to the source.

Finding source in stack trace

For chrome

Open the settings and enable "Log XMLHttpRequests"

Log XMLHttpRequests setting

Launch AJAX again and it will appear in the console. Expand it to see the stack trace.

Finding the stack trace in the console

+2
source

you can use firebug in firefox. This allows you to have breakpoints in javascript code.

You can click the firebug script tab and select a script file and provide breakpoints on all AJAX calls and see which AJAX is called last.

-1
source

Google Chrome contains developer tools: view β†’ developer β†’ developer tools

You are probably most interested in the network tab.

Firebug is also very good for debugging, and the console there will show you ajax requests. Firebug is a firefox addon.

-1
source

Source: https://habr.com/ru/post/947114/


All Articles