I am loading script dynamically using the eval function. Once the
script is loaded using eval, I display the script in the script window
using the name I set for it at the end of the file. I place a break
point inside a function that is only displaying an alert box. Once I
call the function I see the alert box but the break point does not
hit. Is there something I am missing?
Script.js file:
function MyScripts() {
this.ShowMessage = function ShowMessage() {
debugger;
alert("Message");
};
}
o = new MyScripts();
//@ sourceURL=Script.js
program script:
<div>
<script type="text/javascript">
var o = null;
function GetScript () {
$.ajax({url: '../../Scripts/
Script.js', datatype: 'text', async: false, cache: false, success:
function (c) { eval(c); }});
}
</script>
</div>
</body>
</html>
I call GetScript() from console and it loads the script. Then I call
o.ShowMessage().
Network Cache setting in chrome is disabled and cache is disabled in
the ajax call.
I was able to make to break execution by putting "debugger;" on top of
the alert('Message') in Script.js
but break point doesn't work. Also...
When I change the script and comment out the debugger line, it doesn't
break execution but I don't see it commented it out
in the script view for Script.js so it's not refreshing the script
correctly. It only loads the script
after the first GetScript call. So in summary, break point is not
hitting and Script.js view is not refreshing in
in chrome.
Screen shots:
https://lh5.googleusercontent.com/-98z_bYX-SdA/Ts3LiKcfZTI/AAAAAAAAAf4/gfm5ItBar4A/w891-h433-k/Debug.jpg
https://lh6.googleusercontent.com/-YwGnMOYyZGI/Ts3LiB4gP6I/AAAAAAAAAf0/sKQ49pU03X8/w500-h265-k/NoRefreshDebug.jpg