Sending POST request in firefox addon (javascript) - Stack Overflow

With a firefox addon (javascript) I'm trying to send a POST request to a server to get a session I

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
Add a ment  | 

1 Answer 1

Reset to default 5

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./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

相关推荐

  • Sending POST request in firefox addon (javascript) - Stack Overflow

    With a firefox addon (javascript) I'm trying to send a POST request to a server to get a session I

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信