# Ajax Help: Multiple Updates -?

**URL:** <https://www.ruby-forum.com/t/ajax-help-multiple-updates/51032>\
**Category:** Rails\
**Created:** [December 24, 2005, 4:55am UTC](https://www.ruby-forum.com/t/ajax-help-multiple-updates/51032 "2005-12-24T04:55:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmarmer1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rmarmer1](https://www.ruby-forum.com/u/rmarmer1)\
**Post date:** [December 24, 2005, 4:55am UTC](https://www.ruby-forum.com/t/ajax-help-multiple-updates/51032/1 "2005-12-24T04:55:15Z")

</div>

Hi!

Wondering if anyone can tell me what’s wrong with my code?

I’m trying to use the onChange event of a select list to update multiple  
divs…

Agile Web D. with Rails (p. 403) suggests using “:complete =\>  
eval(request.responseText) instead of :update”

I’ve attempted the following test code:

# in the view

\<select name=“plist”, class=“required”, onchange=“\<%=  
remote\_function(:complete =\> evaluate\_remote\_response, :url =\> { :action  
=\> :updateDivs }) %\>” \>

Select a Person Select a Dog Select a Frog  

 
  

 
  

 
  

 

# controller

```
def updateDivs
    render(:layout => false)
end

```

# updateDivs.rhtml

\<%= javascript\_tag(

update\_element\_function(  
“detail1”, :position =\> :top, :content =\> “testData1” ) +

update\_element\_function(  
“detail2”, :position =\> :top, :content =\> “testData2” ) +

update\_element\_function(  
“detail3”, :position =\> :top, :content =\> “testData3” ) +

update\_element\_function(  
“detail4”, :position =\> :top, :content =\> “testData4” )) %\>

I don’t get any errors, but the testdata is not inserted into the divs  
either.

The example in the book replaces the :update with a :complete, but this  
is done on a “link\_to\_remote()” not on a “remote\_function()” as I have  
done… I assumed that this would be OK because the documentation says  
that remote\_function “Takes the same arguments as link\_to\_remote”?!?

Just for grins I tried adding the following:

```
 <%= link_to_remote "Try Me",
  :complete => "eval(request.responseText)",
  :url => { :action => :updateDivs } %>

```

Again, no errors, but no output!

Both the link & the select onchange fire the updateDivs method & produce  
exactly the same log output for both:

link/“Try Me” log output:  
Processing TestemController#updateDivs (for 127.0.0.1 at 2005-12-23  
22:41:17) [POST]  
Parameters: {“action”=\>“updateDivs”, “controller”=\>“testem”}  
Rendering testem/updateDivs  
Completed in 0.01366 (73 reqs/sec) | Rendering: 0.00871 (63%) | 200 OK  
[[http://localhost/testem/updateDivs](http://localhost/testem/updateDivs)]

Select/onChange log output:  
Processing TestemController#updateDivs (for 127.0.0.1 at 2005-12-23  
22:41:23) [POST]  
Parameters: {“action”=\>“updateDivs”, “controller”=\>“testem”}  
Rendering testem/updateDivs  
Completed in 0.00775 (129 reqs/sec) | Rendering: 0.00353 (45%) | 200 OK  
[[http://localhost/testem/updateDivs](http://localhost/testem/updateDivs)]

Any help would be appreciated, I’m really stuck!

Thanks!

---

<div class="post-metadata">

**Author:** ![rmarmer1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rmarmer1](https://www.ruby-forum.com/u/rmarmer1)\
**Post date:** [December 24, 2005, 8:18pm UTC](https://www.ruby-forum.com/t/ajax-help-multiple-updates/51032/2 "2005-12-24T20:18:37Z")

</div>

randy marmer wrote:

> update\_element\_function(  
> “detail3”, :position =\> :top, :content =\> “testData3” ) +
> 
> update\_element\_function(  
> “detail4”, :position =\> :top, :content =\> “testData4” )) %\>
> 
> I don’t get any errors, but the testdata is not inserted into the divs  
> either.

Get rid of the “javascript\_tag” wrapper. The remote response is being  
evaluated, so you don’t want to rap it in tags.

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![rmarmer1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rmarmer1](https://www.ruby-forum.com/u/rmarmer1)\
**Post date:** [December 24, 2005, 11:11pm UTC](https://www.ruby-forum.com/t/ajax-help-multiple-updates/51032/3 "2005-12-24T23:11:31Z")

</div>

Mark Reginald J. wrote:

> randy marmer wrote:
> 
> > update\_element\_function(  
> > “detail3”, :position =\> :top, :content =\> “testData3” ) +
> > 
> > update\_element\_function(  
> > “detail4”, :position =\> :top, :content =\> “testData4” )) %\>
> > 
> > I don’t get any errors, but the testdata is not inserted into the divs  
> > either.
> 
> Get rid of the “javascript\_tag” wrapper. The remote response is being  
> evaluated, so you don’t want to rap it in tags.

INDEED! Thanks!
