6

I read about function 'Request' as this link: https://addons.mozilla.org/en-US/developers/docs/sdk/1.1/packages/addon-kit/docs/request.html

And I would like to use the "post" method. There is no explaination or example on how to send a variable from JS to my server with the post method. How can I do it?

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
Roy
  • 251
  • 3
  • 10

1 Answers1

10

You just change the get() call in the example on that page with post().

exports.main = function() {
    var Request = require("request").Request;
    Request({
      url: "http://google.com/",
      content: {q: "test"},
      onComplete: function (response) {
        console.log(response.text);
      }
    }).post();
};
Nickolay
  • 31,095
  • 13
  • 107
  • 185
  • Thanks my friend, but you answered only about my first question. my second one is about how can i send values from javascript to the post method. if you do not understand i will trying to explain better Thanks for your help – Roy Oct 23 '11 at 21:46
  • @Roy: the 'content: {q: "test"},' line does that. If you don't see the effect on the server side, you should really provide details about your server side. – Nickolay Oct 23 '11 at 22:12