Google chrome extension 扩展can';不做ajax请求

Google chrome extension 扩展can';不做ajax请求,google-chrome-extension,Google Chrome Extension,我想根据ajax请求的答案操作一个web页面。基本上,我会在youtube中搜索页面标题,并检索第一个youtube var search_input = $("#title").text(); var keyword= encodeURIComponent(search_input); // Youtube API var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&max-

我想根据ajax请求的答案操作一个web页面。基本上,我会在youtube中搜索页面标题,并检索第一个youtube

var search_input = $("#title").text();
var keyword= encodeURIComponent(search_input);
// Youtube API 
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&max-results=1&v=2&alt=jsonc'; 

$.ajax
({
type: "GET",
url: yt_url,
dataType:"jsonp",
success: function(response)
{

console.log("succeded");

if(response.data.items)
{
$.each(response.data.items, function(i,data)
{
var video_id=data.id;
var video_title=data.title;
var video_viewCount=data.viewCount;
// IFRAME Embed for YouTube
var video_frame="<iframe src='http://www.youtube.com/embed/"+video_id+"' frameborder='0' type='text/html'></iframe>";

var final="<div>"+video_frame+"</div><div id='count'>"+video_viewCount+" Views</div>";

$("#videos").html(final); // Result

});
}
else
{
$("#videos").html("<div id='no'>No Video</div>");
}
}
});

扩展抛出未捕获引用错误:在尝试发出ajax请求时未定义jQuery1100021788313053548336_1393869626682。我遗漏了什么?

当从注入网页的内容脚本执行跨站点XHR时,您需要在清单的“权限”部分声明您希望能够连接到的url模式,就像在您自己的一个独立页面中执行XHR一样(如背景页面、浏览器操作弹出窗口等)

见:

{
    "content_scripts": [
        {
            "matches": [
                "https://*.website.com/*",
                "*://*.youtube.com/*"
            ],
            "js": [
                "jquery.js",
                "mymanipulatır.js"
            ]
        }
    ],
    "name": "Name",
    "icons": {
        "128": "128x128.png"
    },
    "homepage_url": "http://github.com/",
    "version": "1.4",
    "manifest_version": 2,
    "developer": {
        "name": "may"
    },
    "description": "youtube"
}