最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google chrome - TypeError in Javascript console - Stack Overflow

programmeradmin0浏览0评论

I'm getting an error in my JavaScript console in Chrome

TypeError: Cannot call method 'xxx' of undefined

Firebug reports in Firefox;

TypeError: t is undefined

T and xxx are just examples.

The site I'm working on is jammed full of plugins, jQuery and other random and possibly bad code. It's plicated and probably not worth listing every bit of javascript in there.

So my question is; given the situation, how can I trace this error back to the offending piece of code? And - is that even possible? Given the myriad of variables, xxx and T mean nothing to me.

Chrome seems to have more insight, with error properties such as get stack, set stack, message and __proto__, but expanding these just seems to send me on an endless journey of prototype > constructor > prototype > constructor ... ad nauseum.

Can these error messages guide me to anything useful, such as where exactly the error has occurred - what file, what variable, name of a function ... anything?

I realise this is probably a pretty basic question but I'm stuck. Any hints or pointers really appreciated! I promise I'll read more Javascript books after this. Maybe go on a course. Or maybe I'll give up...

I'm getting an error in my JavaScript console in Chrome

TypeError: Cannot call method 'xxx' of undefined

Firebug reports in Firefox;

TypeError: t is undefined

T and xxx are just examples.

The site I'm working on is jammed full of plugins, jQuery and other random and possibly bad code. It's plicated and probably not worth listing every bit of javascript in there.

So my question is; given the situation, how can I trace this error back to the offending piece of code? And - is that even possible? Given the myriad of variables, xxx and T mean nothing to me.

Chrome seems to have more insight, with error properties such as get stack, set stack, message and __proto__, but expanding these just seems to send me on an endless journey of prototype > constructor > prototype > constructor ... ad nauseum.

Can these error messages guide me to anything useful, such as where exactly the error has occurred - what file, what variable, name of a function ... anything?

I realise this is probably a pretty basic question but I'm stuck. Any hints or pointers really appreciated! I promise I'll read more Javascript books after this. Maybe go on a course. Or maybe I'll give up...

Share Improve this question asked May 4, 2013 at 2:44 NathanBarleyNathanBarley 852 silver badges4 bronze badges 3
  • 1 click on the error and it'll take you to the code (in FireBug any console.log and error shows where it came from on the right side). If came from jquery than it's more likely the error is caused by your code calling the jQuery function. Get the unminified version, break on error and inspect the call stack. – HMR Commented May 4, 2013 at 2:47
  • 1 Huh ... I used the un-minified version of a couple of plugins and pop, it started working. The chief offender seemed to be something called jCarousel. Truth is, I have no idea what I'm doing. And I've been up for 2 days, as my project manager has predicted the end of the world on sunday. If you answer this question I'll give you the green tick - thanks! – NathanBarley Commented May 4, 2013 at 3:08
  • I'll add it to my answer. Good to see it is solved. – HMR Commented May 4, 2013 at 3:14
Add a ment  | 

1 Answer 1

Reset to default 3

In Firebug go to the script tab then click on "break on next" (left red circle). When there is a javascript error the script will be paused there. You can select the stack tab (right circle). In the call stack you can click on the lines and it will take you to the code.

If you can't figure out what caused it still could you please copy and paste the call stack?

Somtimes you might want to see what 3rd party libraries are doing; it is easier to see what is going on if you use the unminified versions of those libraries during development.

发布评论

评论列表(0)

  1. 暂无评论