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.
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.)
Make sure you add
var req = new XMLHttpRequest();
You don't need an extension, plain JavaScript can do this:
Asynchronous cross-domain POST request via JavaScript?