# Trying to use RJS, raw Try(my javascript) catch is displayed on page

**URL:** <https://www.ruby-forum.com/t/trying-to-use-rjs-raw-try-my-javascript-catch-is-displayed-on-page/130760>\
**Category:** Rails\
**Created:** [March 3, 2008, 3:53am UTC](https://www.ruby-forum.com/t/trying-to-use-rjs-raw-try-my-javascript-catch-is-displayed-on-page/130760 "2008-03-03T03:53:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/51bf81/32.png) [@sweiss](https://www.ruby-forum.com/u/sweiss)\
**Post date:** [March 3, 2008, 3:53am UTC](https://www.ruby-forum.com/t/trying-to-use-rjs-raw-try-my-javascript-catch-is-displayed-on-page/130760/1 "2008-03-03T03:53:47Z")

</div>

def index  
redirect\_to(:action =\> ‘test’)  
end

def test  
render :update do |page|  
page \<\< ’ ’  
end  
end

mozilla just displayes the following, my function is defined in the  
layout and my goal is just to call this javascript function when this  
page is loaded, don’t know how why this won’t work, this is just basic  
stuff.

try {

} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(’ \<SCRIPT  
type=“text/javascript”\>\nmyfunction(“pics\\test1.jpeg”);\n \</  
script\>’); throw e }

---

<div class="post-metadata">

**Author:** ![sweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/51bf81/32.png) [@sweiss](https://www.ruby-forum.com/u/sweiss)\
**Post date:** [March 3, 2008, 4:16am UTC](https://www.ruby-forum.com/t/trying-to-use-rjs-raw-try-my-javascript-catch-is-displayed-on-page/130760/2 "2008-03-03T04:16:19Z")

</div>

sweiss wrote:

> def index

Did you remember to use the javascript\_include tags, and do you have  
javascript enabled for that particular browser…

ilan

---

<div class="post-metadata">

**Author:** ![sweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/51bf81/32.png) [@sweiss](https://www.ruby-forum.com/u/sweiss)\
**Post date:** [March 3, 2008, 5:00am UTC](https://www.ruby-forum.com/t/trying-to-use-rjs-raw-try-my-javascript-catch-is-displayed-on-page/130760/3 "2008-03-03T05:00:41Z")

</div>

yep javascript is enabled, and the head of my rhtml template looks  
like such

 Your title \<%= javascript\_include\_tag :defaults %\> \<%= active\_scaffold\_includes %\> function myfunction(src) {

On Mar 2, 9:16 pm, Ilan B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![sweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/51bf81/32.png) [@sweiss](https://www.ruby-forum.com/u/sweiss)\
**Post date:** [March 4, 2008, 10:27am UTC](https://www.ruby-forum.com/t/trying-to-use-rjs-raw-try-my-javascript-catch-is-displayed-on-page/130760/4 "2008-03-04T10:27:50Z")

</div>

how is the remote method ‘test’ getting called from the view.

Do not include an :update parameter, otherwise the view is expecting a  
simple render such as  
render :text=\>‘Replaced with this’ and wont understand the  
render :update response block.

Tonypm

---

<div class="post-metadata">

**Author:** ![sweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/51bf81/32.png) [@sweiss](https://www.ruby-forum.com/u/sweiss)\
**Post date:** [September 23, 2008, 9:25am UTC](https://www.ruby-forum.com/t/trying-to-use-rjs-raw-try-my-javascript-catch-is-displayed-on-page/130760/5 "2008-09-23T09:25:07Z")

</div>

Hi,  
have the same problem have You solved it ?  
Can You post the solution

Thanks

Erhard

tonypm wrote:

> how is the remote method ‘test’ getting called from the view.
> 
> Do not include an :update parameter, otherwise the view is expecting a  
> simple render such as  
> render :text=\>‘Replaced with this’ and wont understand the  
> render :update response block.
> 
> Tonypm
