在控制台没有方法domReady错误,即使domReady被调用

no method domReady error in console even though domReady gets called

本文关键字:domReady 即使 调用 错误 有方法 控制台      更新时间:2023-09-26

我是Javascript新手,所以请原谅我省略了这个问题。

我有一个脚本来抓取我最新的twitter帖子,并把它放在我的博客上:

http://www.joshkerr.com

它不工作。我在控制台中看到的错误是"no method domReady"。我写的另一个脚本运行得很好,如果我逐步执行我的函数,工作得很好。

这里是奇怪的部分。如果在文件中进一步包含jquery,则Twitter对象可以正常工作,但搜索http://www.joshkerr.com/search/停止工作。所以我怀疑某种命名空间的问题正在发生。

如何让我的Twitter对象再次工作?

看起来jeesh.min.js可能正在痛击jQuery的$ object。您的搜索页面抛出错误"对象函数h(a,b){返回g(a,b)}没有方法'getJSON'"。js文件包含"function h(a,b){return g(a,b)}" getJSON是一个jQuery方法,好了。我看到你的搜索页面包含一个像

这样的块
$(document).ready(function() {
    // Your code here
});

像这样包装这样的代码通常被认为是好的做法

(function($) {
    $(document).ready(function() {
        // Your code here
    });
})(jQuery);