简体   繁体   English

从firefox插件发出异步xml请求

[英]make asynchronous xml request from firefox addon

i'm trying to implement xml request in firefox extension when i tried to do that xmlrequest is not defined. 我试图在firefox扩展中实现xml请求,当我试图这样做时,xmlrequest没有定义。 i can make call from contentscript but i'm not able to make it from main.js 我可以从内容脚本打电话,但我无法从main.js进行调用

i tried Request(options) 我试过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 但我需要的是我想发出异步请求

you need to incude const {Cc, Ci} = require("chrome"); 你需要包括const {Cc, Ci} = require("chrome"); in main.js and 在main.js和

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM