Reputation: 325
I want to be able to send out a request from my plugin (with the cookies of the page)
var widgets = require("sdk/widget");
var tabs = require("sdk/tabs");
var self = require("sdk/self");
var Request = require("sdk/request").Request;
var widget = widgets.Widget({
id: "mozilla-link",
label: "Mozilla website",
contentURL: "http://www.favicon.cc/logo3d/33101.png",
onClick: function () {
var worker = tabs.activeTab.attach({
contentScriptFile: self.data.url('scanner.js')
});
worker.port.emit('scanner');
}
});
and the worker script
self.port.on("scanner", function () {
var http = Request({ url:'..', onComplete: function(Response) {}}).get();
});
but I am told that request is not defined... even if i try to define it in the worker script.
ReferenceError: Request is not defined
Upvotes: 0
Views: 285
Reputation: 5830
page workers are just like any other web page, so in the worker you would use xmlhttprequest. if you want to use request, you must do so in your addon's main.js file. If you want to make cross-domain requests, you will need to set the permissions property in your package.json file:
Upvotes: 1