From my recent question, I already created some JavaScript function for dynamic loading partial view. So, I can\'t debug any dynamic loading JavaScript. Because all of loade
For current Google Chrome browser or other modern browsers, you can easily search for any evaluated code with developer tool like the following images.
Create some breakpoint and execute function to test it.
Try adding a "debugger;" statement in the javascript you're adding dynamically. This should cause it to halt at that line regardless of breakpoint settings.
Yes, It is (now) possible to debug dynamically loaded JavaScript using Google Chrome!
No need to add extra debugger;
or any other attribute for dynamically loaded JS file. Just follow the below steps to debug:
My tech lead just showed a super-easy way to debug dynamically loaded Javascript methods.
GetAdvancedSearchConditonRowNew
As an example, I'm loading JS file when I click on a button using ajax
call.
network
tab in google chrome dev toolsRetrieveAllTags?_=1451974716935
)initiater
and you'll find your dynamically loaded JS file(with prefix VM*
).VM*
file to open.I'm using google chrome for that purpose.
In chrome at scripts tab you can enable 'pause on all exceptions'
And then put somewhere in your code line try{throw ''} catch(e){}
. Chrome will stop execution when it reaches this line.
EDIT: modified image so it would be clearer what I'm talking about.
Using Google Chrome (or Safari) Developers Tool, you can run JavaScript line by line.
Developer Tool >
Scripts >
Choose which script you want to debug >
pause sign on the right side
Or set breakpoints by click the line number
In Firebug, you should be able to see that script after the page is loaded and the script is injected. When you do, you can set a breakpoint in the appropriate place, and it'll be preserved when you refresh the page.