# Net::HTTP, Threads and AJAX

**URL:** <https://www.ruby-forum.com/t/net-http-threads-and-ajax/129860>\
**Category:** Ruby\
**Created:** [February 22, 2008, 4:01am UTC](https://www.ruby-forum.com/t/net-http-threads-and-ajax/129860 "2008-02-22T04:01:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skuunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@skuunk](https://www.ruby-forum.com/u/skuunk)\
**Post date:** [February 22, 2008, 4:01am UTC](https://www.ruby-forum.com/t/net-http-threads-and-ajax/129860/1 "2008-02-22T04:01:18Z")

</div>

Hello,  
I was wondering if anyone had solved this issue before.

Basically I am calling a 3rd party information service using Net::HTTP  
which I would like to proxy through my Rails app so that I can access  
it via an xmlhttp request using JavaScript.

This service is not 100% reliable so while I can set a small timeout,  
while the service is being pinged it stops all the other processes  
from being run. I would like to set it up so that it happens as a  
background process and then after a certain amount of time pops up.

I have tried the following, but all that happens is that Rails  
complains that it can’t find a template.

def index  
wgw\_server = WGWServer.new  
Thread.new {  
render :text =\> wgw\_server.proxy(params[:id] + ‘?’ +  
request.env[‘QUERY\_STRING’], params[:callback],  
params[:callbackParam])  
}  
end

wgw\_server.proxy contains the code which handles the Net::HTTP  
request.

Any ideas?

Thanks
