Javascript 未捕获引用错误:未定义JQuery23099916159505955875_1389540514154

Javascript 未捕获引用错误:未定义JQuery23099916159505955875_1389540514154,javascript,jquery,google-chrome-extension,embedly,Javascript,Jquery,Google Chrome Extension,Embedly,我正在尝试将embed.ly库放在google chrome扩展中。但是当我运行以下代码时 $.embedly.defaults.key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; $.embedly.extract('http://embed.ly').progress(function(data){alert(data.title)}); 我得到这个错误: 未捕获引用错误:未定义jqueryxxxxxxxxxxxxxxxxx\uxxxxxxxxxxxx J

我正在尝试将embed.ly库放在google chrome扩展中。但是当我运行以下代码时

 $.embedly.defaults.key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
 $.embedly.extract('http://embed.ly').progress(function(data){alert(data.title)});
我得到这个错误:

未捕获引用错误:未定义jqueryxxxxxxxxxxxxxxxxx\uxxxxxxxxxxxx JQuery已正确加载并正常工作,但它会继续加载,并在错误消息中未定义的JQuery名称上附加一个新的数字(看起来像时间戳)

当我单击错误链接时,提取的内容看起来是这样的

jQuery20309916159505955875_1389540514154([{"provider_url": "http://embed.ly", "description": "Embedly delivers the ultra-fast, easy front-end tools developers need to build richer sites and apps.", "embeds": [], "safe": true, "provider_display": "embed.ly", "related": [], "favicon_url": "http://embed.ly/static/images/favicon.ico?v=0b3ad", "authors": [], "images": [{"caption": null, "url": "http://embed.ly/static/images/logos/logo_color.png?v=4b245", "height": 127, "width": 399, "colors": [{"color": [0, 0, 2], "weight": 0.80712890625}, {"color": [64, 196, 232], "weight": 0.1484375}, {"color": [246, 250, 251], "weight": 0.04443359375}], "entropy": 0.947677537089, "size": 23650}, {"caption": null, "url": "http://embed.ly/static/images/sketches/publishers-200.png?v=081c0", "height": 200, "width": 200, "colors": [{"color": [106, 209, 226], "weight": 0.8740234375}, {"color": [120, 80, 126], "weight": 0.1259765625}], "entropy": 2.4077095600808898, "size": 36127}], "cache_age": 70944, "lead": null, "language": "English", "original_url": "http://embed.ly", "url": "http://embed.ly/", "media": {}, "title": "Front-end developer tools for websites and apps | Embedly", "offset": null, "content": null, "entities": [], "favicon_colors": [{"color": [16, 172, 229], "weight": 0.450439453125}, {"color": [0, 4, 5], "weight": 0.435546875}, {"color": [242, 250, 252], "weight": 0.114013671875}], "keywords": [{"score": 17, "name": "apps"}, {"score": 15, "name": "websites"}, {"score": 14, "name": "embedding"}, {"score": 10, "name": "resize"}, {"score": 9, "name": "elements"}, {"score": 9, "name": "tool"}, {"score": 9, "name": "display"}, {"score": 8, "name": "articles"}, {"score": 7, "name": "smarter"}, {"score": 7, "name": "keywords"}], "published": null, "provider_name": "Embed", "type": "html"}])
这看起来像JSONP

您不应该在内容脚本中使用JSONP,因为JSONP是通过在文档中插入
标记来工作的,该标记使用JSONP请求的结果调用函数。但是,在Chrome的内容脚本中,该脚本的格式与页面不同(在页面中插入了
标记)。因此,您会得到一个关于未定义函数的错误

解决此问题的正确方法是在清单文件中声明正确的权限,并使用常规AJAX+JSON

在您的特定示例中,我看到以下代码片段:


它是JSONP,jQuery在其中添加了一个带有随机数的回调函数。没有比这更多的东西,很难说出确切的位置和原因。
$.ajax({
    url: self.build(method, batch, options),
    dataType: 'jsonp',
    success: function(data){
        ...
    }
});
{
    ...
    "permissions": [
        "*://*.embed.ly/*"
    ],
    ...
}