2012-11-23 111 views
-2

可能重複:
Make this HTTP POST request in rubyPOST請求在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'); 
    } 
}); 

回答

1

退房HTTParty,大寶石https://github.com/jnunemaker/httparty

例子:

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

雖然我相信這是synchronous-不要可以引用我這句話雖然