Use jquery in background of firefox addons

I am very new in addons

I searched a lot there is some answer for this question they didn’t worked for me or I can’t find how to use them to resolve the problem!

The problem is using jquery in background of addons here is my manifest.json:

{

  "manifest_version": 2,
  "name": "my addons",
  "version": "1.0",

  "description": "my addons",
  "browser_action": {
    "browser_style" : true
  },
  "background": {
    // "page": "background/background.html"
    "scripts": [
      "jquery-3.js",
      "background/test.js"
    ]
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": [
        "lib/jquery-3.2.1.js",
        "lib/alert.js"
      ]
    }
  ]

}

Also it’s test.js that is my background script:

console.log("befor get");
$.get("example.com", function( data ) {
  console.log(data);
});
console.log("after get");

And in the output I get this:
befor get
after get
Notting else!


This is because you must add a permission for “example.com” if you want to do external HTTP requests.

1 Like