# How to refresh multiple DIV on a single Ajax Call

**URL:** <https://www.ruby-forum.com/t/how-to-refresh-multiple-div-on-a-single-ajax-call/158284>\
**Category:** Rails\
**Created:** [January 21, 2009, 4:39pm UTC](https://www.ruby-forum.com/t/how-to-refresh-multiple-div-on-a-single-ajax-call/158284 "2009-01-21T16:39:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sauravsuman012](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@sauravsuman012](https://www.ruby-forum.com/u/sauravsuman012)\
**Post date:** [January 21, 2009, 4:39pm UTC](https://www.ruby-forum.com/t/how-to-refresh-multiple-div-on-a-single-ajax-call/158284/1 "2009-01-21T16:39:18Z")

</div>

Hi all ,

I have to refresh three div in a single ajax call …  
Anybody having any Idea . Please let me help , It would be great for me.

Thanks In Advance

---

<div class="post-metadata">

**Author:** ![sauravsuman012](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@sauravsuman012](https://www.ruby-forum.com/u/sauravsuman012)\
**Post date:** [January 21, 2009, 4:57pm UTC](https://www.ruby-forum.com/t/how-to-refresh-multiple-div-on-a-single-ajax-call/158284/2 "2009-01-21T16:57:24Z")

</div>

Kumar S. wrote:

> Hi all ,
> 
> I have to refresh three div in a single ajax call …  
> Anybody having any Idea . Please let me help , It would be great for me.
> 
> Thanks In Advance

I use render :update in my action. For example, if I have a drop down of  
stuff and I want to add to a list when I select something from that drop  
down but at the say time remove from the drop down what I just selected  
I would say something like:

render :update do |x|  
page.replace\_html ‘stuff\_to\_select’, :partial =\> ‘partial\_1’  
page.replace\_html 'list\_of\_stuff, :partial =\> ‘partial\_2’  
page.replace\_html ‘message’, :inline =\> ‘Stuff updated’  
end

Assuming that you have the divs names correctly this would update two  
partials and display a message in another. I usually use these in  
conjunction with link\_to\_remote or remote\_form\_tag. If you are using  
these helpers, don’t include the :update option in your helper as you  
will get strange output displayed in your divs. Hope this helps,

-S

---

<div class="post-metadata">

**Author:** ![sauravsuman012](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@sauravsuman012](https://www.ruby-forum.com/u/sauravsuman012)\
**Post date:** [January 21, 2009, 5:35pm UTC](https://www.ruby-forum.com/t/how-to-refresh-multiple-div-on-a-single-ajax-call/158284/3 "2009-01-21T17:35:09Z")

</div>

Shandy N. wrote:

> Kumar S. wrote:
> 
> > Hi all ,

> I use render :update in my action. For example, if I have a drop down of  
> stuff and I want to add to a list when I select something from that drop  
> down but at the say time remove from the drop down what I just selected  
> I would say something like:
> 
> render :update do |x|  
> page.replace\_html ‘stuff\_to\_select’, :partial =\> ‘partial\_1’  
> page.replace\_html 'list\_of\_stuff, :partial =\> ‘partial\_2’  
> page.replace\_html ‘message’, :inline =\> ‘Stuff updated’  
> end

Hi thanks for help but i am using form\_remote\_tag on my page and  
updating the div there . The code is  
\<%= form\_remote\_tag({:url=\>{:controller=\>‘image\_builders’,  
:action =\>‘image\_creation’}, :update =\>‘photo’,  
:html=\>{:onsubmit=\>‘UrlGeneration(this)’}})%\>

And I have to update the Div(sample1,sample2,sample4) here like photo i  
updating .  
Do you have any suggestion, if yes please let me know.

Thanks In Advance
