[英]make asynchronous xml request from firefox addon
我试图在firefox扩展中实现xml请求,当我试图这样做时,xmlrequest没有定义。 我可以从内容脚本打电话,但我无法从main.js进行调用
我试过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];
}
});
这是工作
但我需要的是我想发出异步请求
你需要包括const {Cc, Ci} = require("chrome");
在main.js和
var httprequest=Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.