Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 将文件传递到服务器的Chrome扩展名_Jquery_Google Chrome_Google Chrome Extension - Fatal编程技术网

Jquery 将文件传递到服务器的Chrome扩展名

Jquery 将文件传递到服务器的Chrome扩展名,jquery,google-chrome,google-chrome-extension,Jquery,Google Chrome,Google Chrome Extension,我正在尝试创建一个chrome扩展,允许用户右键单击一个文件并选择将其发送到一个在线服务,然后该服务将对该文件执行某些操作(目前还没有完成)。但是我很难让它工作。我对jquery非常陌生,所以这可能是一个简单的修复 function uploadfile(info) { var fileurl = info.srcUrl; var file; $.get(fileurl, function(data) { file = data;

我正在尝试创建一个chrome扩展,允许用户右键单击一个文件并选择将其发送到一个在线服务,然后该服务将对该文件执行某些操作(目前还没有完成)。但是我很难让它工作。我对jquery非常陌生,所以这可能是一个简单的修复

function uploadfile(info)
{
    var fileurl = info.srcUrl;

    var file;
    $.get(fileurl, function(data) {
            file = data;
            alert(fileurl);
    });
}

chrome.contextMenus.create({title: "send somewhere", contexts:["image"], onclick: uploadfile});
alert();
警报只是我尝试调试的方式(对更好的方式非常开放)。还有我的清单:

{
   "name": "Practice",
   "version": "0.1",
   "manifest_version": 2,
   "description": "Practice",
   "icons": {
      "16": "icon1.png",
      "48": "icon2.png"
   },
   "background": {
      "scripts": ["background.js"]
    },
   "permissions": [ "contextMenus",
      "tabs",
      "https://*/*",
      "http://*/*"
      ],
   "content_scripts": [ 
    {
      "matches": ["http://*/*"],
      "js": ["jquery.js"]
} ]


}

回复:警报:您可以使用
console.log
background.js
之前,在后台脚本数组中列出
jquery.js
。另请参阅如何将chrome调试工具与后台脚本一起使用。这解决了所有问题。谢谢你。