2010-12-17 40 views
1

当我打开我的网页使用jQuery的,我得到以下错误:jQuery的错误在启动时

Uncaught TypeError: Cannot call method 'call' of undefined 
jQuery.jQuery.fn.jQuery.ready test.html:282 
(anonymous function) test.html:15 
jQuery.jQuery.extend.ready 

这上面追查到

ready: function(fn) { 
    // Attach the listeners 
    jQuery.bindReady(); 

    // If the DOM is already ready 
    if (jQuery.isReady) { 
     // Execute the function immediately 
     fn.call(document, jQuery); 
        ^^^^^^^^^^^^ 

    // Otherwise, remember the function for later 
    } else if (readyList) { 
     // Add the function to the wait list 
     readyList.push(fn); 
    } 

FN是不确定的......有我能看到的其他症状并不是我指出的问题。我引用了jquery.js的本地副本。

<script src="js/jquery-1.4.4.js" type="text/javascript"></script> 

使用谷歌的CDN并没有帮助..不能想象我打这个第一人......

任何人只要有三分球,帮助新手?

在此先感谢, 雅

+0

发布您的html页面的源代码,包括您正在执行的所有脚本。你是否使用除jQuery之外的另一个JS库? – 2010-12-17 23:07:36

+0

您在哪里以及如何定义fn函数作为fn传递? – Javi 2010-12-17 23:09:58

回答

1

什么是你想初始化呢?通常任何需要准备一个页面上是木已成舟,如:

$(document).ready(function(){ 
    //your JS calls, functions, bindings, and whatever 


}); 
+0

这就是它......我的语法错了......我有: – jas 2010-12-17 23:37:21

+0

$(document).ready(init()); – jas 2010-12-17 23:38:16

2

貌似ready本身没有所谓的参数(或一个是undefined)。

+0

感谢您提供真正快速且有用的建议。因此,Ii找出问题所在。仍然不知道为什么会发生......他的情况是这样的: – jas 2010-12-17 23:31:29

1

我猜想,你在等同于网页有码的地方:

$(document).ready(undefined); 

你需要一个函数引用传递到就绪()方法,如图FatherStorm的答复。如果您正在传递函数名称,请确保该函数在您调用ready()的作用域中可用。如果您正在内联定义函数,请检查页面上的语法问题或其他错误。

0

最近我得到的错误:

Uncaught TypeError: Cannot call method 'call' of undefined 

就我而言,我删除我的自定义验证jQuery.validator.addMethod(), 之一,但我忘了从规则中删除。

$("##frmCreate").validate({ 
    rules: { 
     zip: {required: true, maxlength: 6, postalcode:true}, 

在上面的例子中,postalcode是我的自定义验证器。

希望它可以帮助他人..