# Problem using rjs, please help

**URL:** <https://www.ruby-forum.com/t/problem-using-rjs-please-help/172553>\
**Category:** Rails\
**Created:** [July 23, 2009, 8:52am UTC](https://www.ruby-forum.com/t/problem-using-rjs-please-help/172553 "2009-07-23T08:52:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Rand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c6cbf5/32.png) [@Tim\_Rand](https://www.ruby-forum.com/u/Tim_Rand)\
**Post date:** [July 23, 2009, 8:52am UTC](https://www.ruby-forum.com/t/problem-using-rjs-please-help/172553/1 "2009-07-23T08:52:16Z")

</div>

I was having fun with rails right up until ajax. And now want to burn  
the  
whole thing down. Please explain what I am doing wrong here.  
index.html.erb contains:

\<%= javascript\_include\_tag 'prototype' %\> ...

I AM RJS

\<%= link\_to\_remote("hello", :update =\> "rjs", :url =\> {:action =\> "hello\_dude"}) %\>

the controller file contains:  
def hello\_dude  
render :text =\> Time. now  
end

So far everything is works. Now I try use let the rjs file :

change the controller file to  
def hello \_dude  
respond\_to do |format|  
format.js  
end

With the hello\_dude.rjs file containing:  
page.insert\_html :bottom, :rjs, Time.now.to\_s

Here is what shows up in my browser:

try { Element.insert(“RJS”, { bottom: “Wed Jul 22 23:28:17 -0700 2009”  
}); }  
catch (e) { alert(‘RJS error:\n\n’ + e.toString());  
alert(‘Element.insert("RJS", { bottom: "Wed Jul 22 23:28:17 -0700  
2009"  
});’); throw e }  
hello [http://localhost:80/orders?search=shoes#](http://localhost:80/orders?search=shoes#)

I don’t get it. Please help me get rid of this annoying error message.  
Thanks,  
Tim

---

<div class="post-metadata">

**Author:** ![Tim\_Rand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c6cbf5/32.png) [@Tim\_Rand](https://www.ruby-forum.com/u/Tim_Rand)\
**Post date:** [July 23, 2009, 9:28am UTC](https://www.ruby-forum.com/t/problem-using-rjs-please-help/172553/2 "2009-07-23T09:28:35Z")

</div>

Hi  
change

> \<%= link\_to\_remote(“hello”, :update =\> “rjs”, :url =\> {:action =\>  
> “hello\_dude”}) %\>

to

\<%= link\_to\_remote(“hello”, :url =\> {:action =\>\> “hello\_dude”}) %\>

Sijo

---

<div class="post-metadata">

**Author:** ![Tim\_Rand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c6cbf5/32.png) [@Tim\_Rand](https://www.ruby-forum.com/u/Tim_Rand)\
**Post date:** [July 23, 2009, 7:02pm UTC](https://www.ruby-forum.com/t/problem-using-rjs-please-help/172553/3 "2009-07-23T19:02:09Z")

</div>

sijo is right , when you use :update that try to  
update that fragment and send the response to that fragment

before the calling of rjs the response already send to that fragment

---

<div class="post-metadata">

**Author:** ![Tim\_Rand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c6cbf5/32.png) [@Tim\_Rand](https://www.ruby-forum.com/u/Tim_Rand)\
**Post date:** [July 24, 2009, 5:27am UTC](https://www.ruby-forum.com/t/problem-using-rjs-please-help/172553/4 "2009-07-24T05:27:36Z")

</div>

Thank you. It works. I will put the gasoline back in the truck…for  
now.  
Tim
