views:

34

answers:

3

Hi there, I'm a newbie trying to do a simple HTTP post in JS within a Firefox extension..

This isn't passing through the parameters:

var params = "a=1&b=2&c=3"
req.open('POST', 'http://www.mywebsite.com/');
req.send(params);

Any ideas on what I'm doing wrong? Thanks.

A: 

You don't need an extension, plain JavaScript can do this:

http://stackoverflow.com/questions/467008/asynchronous-cross-domain-post-request-via-javascript

Luca Matteis
A: 

Make sure you add

var req = new XMLHttpRequest(); 
Neb
A: 

Make sure you've included the header to tell the server what type of request body you're sending it:

req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

(Assuming req is an XMLHttpRequest created earlier in the code.)

bobince