# Function definition inside script in remote call

**URL:** <https://www.ruby-forum.com/t/function-definition-inside-script-in-remote-call/104931>\
**Category:** Rails\
**Created:** [May 23, 2007, 11:37pm UTC](https://www.ruby-forum.com/t/function-definition-inside-script-in-remote-call/104931 "2007-05-23T23:37:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [May 23, 2007, 11:37pm UTC](https://www.ruby-forum.com/t/function-definition-inside-script-in-remote-call/104931/1 "2007-05-23T23:37:26Z")

</div>

## I’m using remote request to update a div with a table. At the end of the table I have some javascript where I define a function

# start table.rhtml
etc...

|
| |

# end table.rhtml

* * *

But when I try to call that function i got the error “update\_values is  
not defined”.  
I have evalscript:true  
If i put for example alert(‘hello’) after the function, i get the  
alert when the script is loaded, but the function (Conclusion: the  
script is executed but the function is not defined)

## I don’t understand. For example, the function es executed if I change the script to

* * *

But It does not work if I change it to

* * *

* * *

??

Thanks
