3

I'm using Mozilla Add-on Sdk for Firefox to create a small extension. I want to get data from several servers and display it on top left corner on user page. I don't know why, but XMLHttpRequest is not working when I'm trying to read data from servers. Maybe location origins are different and Firefox block it. please very much let me know how to do XMLHttpRequest ? or how to read data from servers with extension built with Add-on Sdk ?

Jigberto
  • 1,513
  • 7
  • 27
  • 50

1 Answers1

7

XHR run from content scripts currently does not allow cross-domain requests ( this is coming in Firefox 24. In the meantime, you need to instead use the request module from your main.js file, and pass along the results to a content script via message passing. There's more detail in the docs:

For a long time now it has been possible to do cross-domain xhr requests from content scripts, please see these docs for details on how to do this.

therealjeffg
  • 5,790
  • 1
  • 23
  • 24
  • While these links may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes – Makyen Dec 22 '14 at 04:09
  • I was just making sure my old answer wasn't misleading anyone. Feel free to expand it the answer - I think that would be a much better contribution to SO/Moz than being pedantic when other people are trying to help. – therealjeffg Dec 22 '14 at 19:24