【问题标题】:POST Request in Ruby [duplicate]Ruby中的POST请求[重复]
【发布时间】:2012-11-12 05:19:39
【问题描述】:

可能重复:
Make this HTTP POST request in ruby

如何在 Ruby 中执行以下 JavaScript 请求?

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');
    }
});

【问题讨论】:

    标签: javascript ruby post request


    【解决方案1】:

    看看 HTTParty,伟大的宝石https://github.com/jnunemaker/httparty

    例子:

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

    虽然我相信它是同步的——但不要引用我的话

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-11
      • 2019-10-15
      • 2023-03-22
      • 2013-06-12
      • 2014-10-03
      • 1970-01-01
      • 2020-03-26
      • 1970-01-01
      相关资源
      最近更新 更多