Pregunta

i'm trying to implement xml request in firefox extension when i tried to do that xmlrequest is not defined. i can make call from contentscript but i'm not able to make 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];

  }
});

it is working

but what i need is i want to make asynchronous request

¿Fue útil?

Solución

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

var httprequest=Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top