admin管理员组文章数量:1357276
I'm just about to freak out. I currently have to work on a website that some other guy did and I am asked to maintain etc. It uses jQuery and a bunch of drupal modules. At some point i get some syntax error, so that some js works, and some does not. My big big problem is to find the syntax error. Neither Firebug, nor WebInspector give me decent information:
Error: uncaught exception: Syntax error, unrecognized expression: //
Yeah… that's it. No lines, no filename, no more hints. Has anyone an idea how to deal with this?
Thanks for any usefull hints.
I'm just about to freak out. I currently have to work on a website that some other guy did and I am asked to maintain etc. It uses jQuery and a bunch of drupal modules. At some point i get some syntax error, so that some js works, and some does not. My big big problem is to find the syntax error. Neither Firebug, nor WebInspector give me decent information:
Error: uncaught exception: Syntax error, unrecognized expression: //
Yeah… that's it. No lines, no filename, no more hints. Has anyone an idea how to deal with this?
Thanks for any usefull hints.
Share Improve this question asked Sep 10, 2010 at 14:14 nocksocknocksock 5,5276 gold badges41 silver badges66 bronze badges 1-
I'm surprised that this is possible. Even if it was generated code that's being evaluated,
eval()
errors still are more informative than your example. – slikts Commented Sep 10, 2010 at 14:30
4 Answers
Reset to default 4you might try a tool like the closure piler, which will give warnings and errors for blocks of code. otherwise, it's brute force with alert('checkpoint');
to determine how far into your code you get before things break.
I believe Chrome's console pinpoints the line of the error.... Right-click on the page > Inspect element, then in the bottom right corner of the window that pops up, click on the red X icon, then click on the link for the error, enable Resource tracking if necessary...
Also, put the code trough JSLint and correct the code accordingly ...
I'd start by menting out all but one javascript include at a time in the html, if possible (unless they're a tangled mess of dependencies). Other than that, can you try using a debugger to step through it line by line? Finally, if it's not too much work, maybe it's worth writing unit tests. It'll also help you fully understand the person's code, and probably identify any deeper logic-level bugs.
JSLint may be what you need, but I bet it finds a lot more problems than just your elusive syntax error.
本文标签: debuggingCan39t find JavaScript Syntax ErrorStack Overflow
版权声明:本文标题:debugging - Can't find JavaScript Syntax Error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743983039a2571161.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论