从 Firefox 书签中呈现的 http-get 中读取内容
我正在尝试让 Firefox 插件从 HTTP get 读取数据,解析结果并将它们作为链接呈现在类似书签的下拉菜单中。
我的问题是:有人有可以执行此操作的示例代码吗?
I'm trying to get a Firefox plugin to read data from a HTTP get, parse the results and present them as links in a bookmark-like drop-down menu.
My quesion then is: Does anyone have any sample code that will do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Robert Walker 出色地描述了如何发送请求。 您可以在此处阅读有关 Mozilla xmlhttprequest 的更多信息。
找到响应(使用罗伯特的代码)
我只想补充一点,可以使用(编辑 - 我没有仔细阅读,谢谢罗伯特)
尽管您提到要解析数据中的链接,但您没有准确指出数据是什么。 您可以将 xmlhttp.responseText 作为 xml 文档,解析出链接,并将其放入菜单列表或任何您喜欢的内容中。
Robert Walker did a great job of describing how to send the request. You can read more about Mozilla's xmlhttprequest here.
I would just add that the response would be found (using Robert's code) using(Edit - i didn't read closely enough, thanks Robert)
You didn't indicate exactly what the data was, although you mentioned wanting to parse links from the data. You could the xmlhttp.responseText as an xml document, parse out the links, and place it into a menulist or whatever you like.
由于我自己从未开发过插件,所以我不确定这在 Firefox 插件中通常是如何完成的,但由于插件脚本是 JavaScript,我可能可以帮助完成加载部分。 假设一个名为 url 的变量包含您想要请求的 URL:
关于此代码的一些注意事项:
Having never developed one myself, I'm not certain how this is typically done in Firefox plugins, but since plugin scripting is JavaScript, I can probably help out with the loading part. Assuming a variable named url containing the URL you want to request:
A couple of notes on this code: