Reputation: 86600
Suppose I have an ajax call created by a page I don't control.
The page itself creates a request, gets the response and continue it's job. None of the page's code is my code.
How can I see which methods will be executed as the callback of that request?
In other words, how can I know what the page will do with the response?
Important: I need to be able to do that for several different calls, so I wish to know that "programmatically".
Isn't there an easy way to list all handlers assigned to an event?
For instance, take the "onreadystatechange
event and find out what listeners were assigned to it?
Upvotes: 0
Views: 38
Reputation: 119837
In Chrome, to locate the code that's firing the AJAX
{}
) on the lower left. Further encounters with a formatted file will show it formatted.To trace the code after a successful AJAX
Chrome: https://developer.chrome.com/devtools/docs/javascript-debugging
Firefox: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Set_a_breakpoint
I need to be able to do that for several different calls, so I wish to know that "programmatically".
That's only possible if you have access (your code can hook to, or is within scope) to any of the functions called in the operation (either override how the request operates, or override something in the callback sequence. If the AJAX happens to use jQuery, follow this answer using AJAX hooks.
Upvotes: 3
Reputation: 2544
Your question is unclear but have you tried ajaxStop from jQuery ?
$(document).ajaxStop(function(){/*Callback here*/});
Upvotes: 1