2010-12-17 41 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是我的自定義驗證器。

希望它可以幫助他人..