Make an asynchronous xml request from Firefox admin

I am trying to implement an xml request in a firefox extension when I tried to make xmlrequest not defined. I can make a call from a document, but I can not do it from main.js

I tried Request(options)

var Request = require("sdk/request").Request;
var httpRequest = Request({
  url: "https://api.twitter.com/1/statuses/user_timeline.json?screen_name=mozhacks&count=1",
  onComplete: function (response) {
    var tweet = response.json[0];

  }
});

works

but I need me to make an asynchronous request

+4
source share
1 answer

you need to specify const {Cc, Ci} = require("chrome");in main.js and

var httprequest=Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); 
+3
source

Source: https://habr.com/ru/post/1534721/


All Articles