-2

Possible Duplicate:
Make this HTTP POST request in ruby

How do you perform the following JavaScript request in Ruby?

url = 'http://www.example.com/';
data 'name=aren&age=22';

$.ajax({
    type: "POST",  
    url: url,
    data: data,
    dataType: "json",

    error: function() {
        console.log('error');
    },
    success: function(data) {
        console.log('success');
    }
});
Community
  • 1
  • 1
aren55555
  • 1,677
  • 1
  • 20
  • 34

1 Answers1

1

Check out HTTParty, great gem https://github.com/jnunemaker/httparty

Example:

response = HTTParty.post(url, body: data)
puts response.body, response.code, response.message, response.headers.inspect

Although I believe it is synchronous- dont quote me on that though

AJcodez
  • 31,780
  • 20
  • 84
  • 118