# Ajax callback w/o model update?

**URL:** <https://www.ruby-forum.com/t/ajax-callback-w-o-model-update/60596>\
**Category:** Rails\
**Created:** [May 15, 2006, 11:49pm UTC](https://www.ruby-forum.com/t/ajax-callback-w-o-model-update/60596 "2006-05-15T23:49:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![leei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5fc32e/32.png) [@leei](https://www.ruby-forum.com/u/leei)\
**Post date:** [May 15, 2006, 11:49pm UTC](https://www.ruby-forum.com/t/ajax-callback-w-o-model-update/60596/1 "2006-05-15T23:49:28Z")

</div>

Is there a way to keep a controller instance variable across a  
link\_to\_remote call?

In essence, I want the call to re-render a partial within my page with  
different display parameters, but without doing another DB call. Is  
there a simple way to do this?

---

<div class="post-metadata">

**Author:** ![leei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5fc32e/32.png) [@leei](https://www.ruby-forum.com/u/leei)\
**Post date:** [May 16, 2006, 4:40am UTC](https://www.ruby-forum.com/t/ajax-callback-w-o-model-update/60596/2 "2006-05-16T04:40:21Z")

</div>

Are the variables short enough that you can serialize them and stuff  
them  
inside parameters in the URL? It’s ugly but functional, and requires no  
back-end help. (Or turn it into a POST for longer strings.)

- James

---

<div class="post-metadata">

**Author:** ![leei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5fc32e/32.png) [@leei](https://www.ruby-forum.com/u/leei)\
**Post date:** [May 16, 2006, 7:21am UTC](https://www.ruby-forum.com/t/ajax-callback-w-o-model-update/60596/3 "2006-05-16T07:21:40Z")

</div>

James M. wrote:

> Are the variables short enough that you can serialize them and stuff them  
> inside parameters in the URL? It’s ugly but functional, and requires no  
> back-end help. (Or turn it into a POST for longer strings.)

Nope. I’m talking a fairly hefty Foo.find(:all, :include =\> […])…

So there’s good reason not to want to re-execute the query just so I can  
redisplay with different parameters.

---

<div class="post-metadata">

**Author:** ![leei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5fc32e/32.png) [@leei](https://www.ruby-forum.com/u/leei)\
**Post date:** [May 16, 2006, 10:58pm UTC](https://www.ruby-forum.com/t/ajax-callback-w-o-model-update/60596/4 "2006-05-16T22:58:15Z")

</div>

Mick S. wrote:

> Is there a problem with storing the results of the query in a session  
> variable?

Not really, although I’d prefer if it didn’t persist to the database or  
filesystem. I’m also concerned about making sure that it gets cleared  
as soon as I leave the page…

Thinking it through a bit further, it seems that there are really only  
two solutions:

1. Store in the session, in which case, I want to get it cleared as soon  
as I leave the page.

- Is there a callback or such that handles this?

1. Create a data structure in JS and do the redisplay entirely on the  
client side.

- Has anyone experience with this? Possible with RJS?

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![leei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5fc32e/32.png) [@leei](https://www.ruby-forum.com/u/leei)\
**Post date:** [May 16, 2006, 12:48pm UTC](https://www.ruby-forum.com/t/ajax-callback-w-o-model-update/60596/5 "2006-05-16T12:48:31Z")

</div>

Is there a problem with storing the results of the query in a session  
variable?
