开发者

Debugging javascript code that comes as part of Ajax Response

So in my website, I use jquery to fetch data through ajax. AS part of开发者_JAVA百科 the ajax response, some of the javascript code comes as well which is executed. The problem is how to debug this javascript in firebug or other tools. This is my experience so far:

  • putting debugger; doesn't work
  • For some javascript, can't set the breakpoint as that script is not yet loaded.
  • even if this new javascript calls some other function thats already loaded (i.e. i can see it in firebug and set a breakpoint), that breakpoint on that function is still not triggered

However, the javascript does executes normally and even things like console.log works but cant seem to debug it..


If you use Google Chrome, check out the answer of this question: https://stackoverflow.com/a/10929430/482916

You need to add in the ajax-loaded JS scripts the following comment:

//@ sourceURL=dynamicScript.js

where dynamicScript.js is the name of the script which will come up in the console.


I know Firebug and the IE developer tools will respect the debugger statement. So I would throw that onto the top of the response.

debugger;

func1();
func2();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜