0

I am currently developing a firefox extension with jpm.when I make an jpm init I have a js file index.js. In this file I can include different sdk with require for example var system = require("sdk/system"); The problem is that if I have another js file I attach to my tab, I go well at my job but worries if I want to include an SDK in the file I get an error

Require is no defined

Require only works in index.js file. How to access a sdk in different js file? Because I want to use the sdk sdk/request to query xmlHttpRequest

simon
  • 1,180
  • 3
  • 12
  • 33
  • 1
    Don't you try to load sdk modules in the content script? If so, it's not allowed, but you can use XMLHttpRequest in those scripts without any module, as it's a part of window global object. – Jakub Rożek Apr 23 '16 at 13:05
  • 1
    Or maybe you can even use [.fetch()](https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch) for a nicer API in the content script. If you want to do cross-site requests, you'll have to [set a flag](https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#permissions) for it. – humanoid Apr 24 '16 at 12:05
  • This link help me : http://stackoverflow.com/questions/19818321/how-can-i-use-xmlhttprequest-from-main-js-in-a-firefox-addon-sdk-extension-or – simon Apr 25 '16 at 08:53

0 Answers0