当我加载使用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 );
}
上面的pn是未定义的......没有其他的症状可以看出我指出了问题。我正在引用jquery.js的本地副本。
<script src="js/jquery-1.4.4.js" type="text/javascript"></script>
使用谷歌cdn也无济于事。不能想象我是第一个打这个... ...
有指点帮助新手的人吗?
提前谢谢, 雅答案 0 :(得分:2)
看起来ready
本身是在没有参数的情况下调用的(或者是undefined
的调用。)
答案 1 :(得分:1)
你想要初始化的是什么?通常,任何需要在页面上完成的事情都可以完成:
$(document).ready(function(){
//your JS calls, functions, bindings, and whatever
});
答案 2 :(得分:1)
我猜你的页面中的代码相当于:
$(document).ready(undefined);
您需要将函数引用传递给ready()方法,如FatherStorm的回复所示。如果要传入函数名称,请确保该函数在您调用ready()的范围内可用。如果要内联定义函数,请检查页面上的语法问题或其他错误。
答案 3 :(得分:0)
最近我收到错误:
Uncaught TypeError: Cannot call method 'call' of undefined
就我而言,我删除了一个自定义验证器jQuery.validator.addMethod()
,
但是我忘了把它从规则中删除。
$("##frmCreate").validate({
rules: {
zip: {required: true, maxlength: 6, postalcode:true},
在上述情况下,邮政编码是我的自定义验证器。
希望它可以帮助别人..