Reputation: 35
With a firefox addon (javascript) I'm trying to send a POST request to a server to get a session ID back, but none of conventional methods seem to work, I already tried xmlhttprequest and getting it with forms isn't possible because it's internal code. Is there a way to get this working, maybe even with the addon SDK?
References to my tries:
Javascript sending data via POST in firefox addon
HTTP POST in javascript in Firefox Extension
Upvotes: 2
Views: 5346
Reputation: 1279
With the new Addon SDK you should use the new Request API instead of XMLHttpRequest. The new Interface is a lot easier to use, too.
Here is a quick example:
// make sure this gets executed BEFORE making the Request
var Request = require("sdk/request").Request;
Request({
url: "http://example.com/hello-world.php",
content: { hello: 'world' },
onComplete: function (response) {
console.log( response.text );
}
}).post();
I suggest you may have a look at this MDN Tutorial: Getting started
Upvotes: 5