# Communication between browser and BackgrounDRb

**URL:** <https://www.ruby-forum.com/t/communication-between-browser-and-backgroundrb/141057>\
**Category:** Rails\
**Created:** [June 21, 2008, 2:06pm UTC](https://www.ruby-forum.com/t/communication-between-browser-and-backgroundrb/141057 "2008-06-21T14:06:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![milo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://www.ruby-forum.com/u/milo)\
**Post date:** [June 21, 2008, 2:06pm UTC](https://www.ruby-forum.com/t/communication-between-browser-and-backgroundrb/141057/1 "2008-06-21T14:06:33Z")

</div>

I’m already using BackgrounDRb to execute a long-running job on an  
application, which is ideal because all it needs to do at the end of the  
job is to e-mail the user telling them the URL to download the results  
of their query. When they start the job a page telling them to wait for  
the e-mail is rendered.  
However, before that stage users will need to do a database search and  
view the results in the browser, so that they may choose what data  
they’d like to send to the really long process. That query has taken to  
running for 2-3 minutes, during which time the browser will time out.  
I’d like to do something like this:

1. Send the job to a worker whilst rendering the “please wait” message  
that I currently have.
2. When the job from (1) is complete, have the worker inform the browser  
so that the user can be re-directed to view the results of their search.

What’s the best way of performing step (2)? Would it be some sort of  
javascript embedded in the “please wait” view that queries the worker,  
and if so could anyone point me in the direction of an example of how  
this might be set up?  
The other thing is that this worker will need access to session[] to  
store the id of the models it finds and I’d also have to pass a very  
large hash of params[] to it in order for the search to be carried out.  
Is that possible?

---

<div class="post-metadata">

**Author:** ![milo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://www.ruby-forum.com/u/milo)\
**Post date:** [June 21, 2008, 4:18pm UTC](https://www.ruby-forum.com/t/communication-between-browser-and-backgroundrb/141057/2 "2008-06-21T16:18:54Z")

</div>

On Sat, Jun 21, 2008 at 5:36 PM, Milo T.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## I’d like to do something like this: The other thing is that this worker will need access to session[] to store the id of the models it finds and I’d also have to pass a very large hash of params[] to it in order for the search to be carried out. Is that possible?

You can save result status in your worker and from rails you can query  
for worker result statue using periodic ajax request.
