I’m trying to return a net http response from a link to remote call; however, I am unsure how to access information returned in the body.
This is what I have so far:
def get_info
uri = URI.parse("somesite")
response = Net::HTTP.get_response(uri)
render :json => {:name => response.body}
end
$(document).ready(function(){
$('#get_info').bind("ajax:success", function(event, data, status, xhr) {
alert(data.name);
});
});
This just dumps the xml returned to the pop up.
If you want to do any kind of fancy stuff with the response I recommend using nokogiri:
Then you can get e.g. the title with just: