调试JavaScript的code,它来作为Ajax响应的一部分 [英] Debugging javascript code that comes as part of Ajax Response

查看:100
本文介绍了调试JavaScript的code,它来作为Ajax响应的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,在我的网站,我使用jQuery通过Ajax来获取数据。作为Ajax响应的一部分,一些JavaScript的code提供其执行也是如此。现在的问题是如何调试这个JavaScript的萤火虫或其他工具。这是我迄今为止的经验:

So in my website, I use jquery to fetch data through ajax. AS part of 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:

  • 将调试;不能正常工作
  • 对于一些javascript,不能设置断点为尚未加载脚本。
  • 即使这个新的JavaScript调用已加载一些其他的功能,这就是(即我可以看到它在Firebug,设置断点),在该函数断点仍然没有触发

不过,JavaScript并执行时正常,甚至像的console.log的作品,但不能似乎调试它..

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

推荐答案

如果你使用谷歌浏览器,检查出这个问题的答案: http://stackoverflow.com/a/10929430/482916

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

您需要在AJAX加载JS脚本添加了如下评论:

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

//@ sourceURL=dynamicScript.js

其中的 dynamicScript.js 的是它会在控制台中的脚本的名称。

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

这篇关于调试JavaScript的code,它来作为Ajax响应的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆