google chrome - TypeError in Javascript console - Stack Overflow

I'm getting an error in my JavaScript console in ChromeTypeError: Cannot call method 'xxx

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745520344a4631231.html

相关推荐

  • google chrome - TypeError in Javascript console - Stack Overflow

    I'm getting an error in my JavaScript console in ChromeTypeError: Cannot call method 'xxx

    18小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信