-2

重複の可能性:
Ruby でこの HTTP POST リクエストを作成します

次の JavaScript リクエストを 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');
    }
});
4

1 に答える 1

1

HTTParty、素晴らしい宝石をチェックしてくださいhttps://github.com/jnunemaker/httparty

例:

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

私はそれが同期していると信じていますが-それについて私を引用しないでください

于 2012-11-23T22:13:59.240 に答える