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
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
Share Improve this question edited May 23, 2017 at 11:44 CommunityBot 11 silver badge asked Apr 12, 2015 at 13:14 PinetraxPinetrax 351 silver badge6 bronze badges 1- This solution here also has a XHR but for non-sdk (which can also be used in sdk) stackoverflow./questions/2471666/ajax-in-firefox-plugin/… – Noitidart Commented Apr 13, 2015 at 14:22
1 Answer
Reset to default 5With 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./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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745350865a4623823.html
评论列表(0条)