# Ruby/ajax strange problem

**URL:** <https://www.ruby-forum.com/t/ruby-ajax-strange-problem/93275>\
**Category:** Rails\
**Created:** [April 30, 2007, 11:08am UTC](https://www.ruby-forum.com/t/ruby-ajax-strange-problem/93275 "2007-04-30T11:08:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@adi](https://www.ruby-forum.com/u/adi)\
**Post date:** [April 30, 2007, 11:08am UTC](https://www.ruby-forum.com/t/ruby-ajax-strange-problem/93275/1 "2007-04-30T11:08:16Z")

</div>

I have a ajax request that loads me a ruby page in my mainArea div:

new Ajax.Request(window, {asynchronous:true, evalScripts:true,  
onSuccess:function(req){$(‘mainArea’).innerHTML=req.responseText}});

where ‘window’ is the ruby page  
In my ruby page i have a javascript function( alert(“test”); )  
If i access directly the ruby page(window) the function it works but if  
i load it with ajax didn’t access the javascript.  
If i put the javascript function in the first page where i make the ajax  
request it’s work, but i don’t wan’t to.  
Many thanks

---

<div class="post-metadata">

**Author:** ![adi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@adi](https://www.ruby-forum.com/u/adi)\
**Post date:** [May 2, 2007, 10:32pm UTC](https://www.ruby-forum.com/t/ruby-ajax-strange-problem/93275/2 "2007-05-02T22:32:18Z")

</div>

adi wrote:

> I have a ajax request that loads me a ruby page in my mainArea div:
> 
> new Ajax.Request(window, {asynchronous:true, evalScripts:true,  
> onSuccess:function(req){$(‘mainArea’).innerHTML=req.responseText}});
> 
> where ‘window’ is the ruby page  
> In my ruby page i have a javascript function( alert(“test”); )  
> If i access directly the ruby page(window) the function it works but if  
> i load it with ajax didn’t access the javascript.  
> If i put the javascript function in the first page where i make the ajax  
> request it’s work, but i don’t wan’t to.  
> Many thanks

I have found the problem.  
Is a bug in evalscripts from ajax.  
thanks
