Kyle
Kyle

Reputation: 2872

Communicating to server from Firefox extension

I'm looking to make an HTTP POST request to a PHP script on a server from a Firefox extension and get JSON in return. The amount of data that I would ideally like to send to the server in one request is too large for a GET request (due to the practical URL length restrictions). Therefore, I cannot use JSONP with a GET request.

Is it possible to access any native Firefox browser component to make a POST request to the server or must an XMLHttpRequest be used? (This extension is being developed for Firefox 4.)

Upvotes: 2

Views: 1109

Answers (1)

Tyler
Tyler

Reputation: 22116

From your comment:

There are origin restrictions when performing cross-domain requests. JSONP is generally the solution for doing requests over different domains, but it is limited in that it is a GET request with an inherent limit on the data being transmitted (due to the practical limitations of URL length). The general limit for URL length is about 2,000 characters. Ideally, I would like to do a single POST request (to avoid the limit on the data being submitted).

Luckily, those origin restrictions don't apply when using XMLHttpRequest from privileged code (like in a Firefox extension) so you can just use it. If it doesn't work, leave more comments or open a new question.

https://developer.mozilla.org/En/Using_XMLHttpRequest

Upvotes: 2

Related Questions