# RJS/Ajax insert\_html problem

**URL:** <https://www.ruby-forum.com/t/rjs-ajax-insert-html-problem/142029>\
**Category:** Rails\
**Created:** [July 2, 2008, 7:17pm UTC](https://www.ruby-forum.com/t/rjs-ajax-insert-html-problem/142029 "2008-07-02T19:17:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [July 2, 2008, 7:17pm UTC](https://www.ruby-forum.com/t/rjs-ajax-insert-html-problem/142029/1 "2008-07-02T19:17:05Z")

</div>

I’m getting weird results using an Ajax call to render a partial. My  
RJS is getting executed properly as nearly as I can tell but instead  
of rendering the partial, it renders the Javascript that should be  
getting executed. Here’s what’s in the RJS file:

page.insert\_html :bottom, :product\_div, :partial =\> ‘test/  
test\_partial’

I tried a simpler test with:

page.insert\_html :bottom, :product\_div, ‘test’

but got similar results. The div element with id “product\_div” gets  
updated with:

try { new Insertion.Bottom(“product\_div”, “test”); } catch (e)  
{ alert(‘RJS error:\n\n’ + e.toString()); alert(‘new  
Insertion.Bottom(“product\_div”, “test”);’); throw e

Seems to me like this is the code that should be executed to put the  
word “test” in the div. The Prototype libraries seem to be loaded just  
fine and the Ajax call goes to the right place and executes properly -  
I just can’t see why it’s doing this. Any ideas on how to go about  
debugging this? Thanks!

---

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [July 2, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/rjs-ajax-insert-html-problem/142029/2 "2008-07-02T19:19:26Z")

</div>

On 2 Jul 2008, at 18:16, Matt W. wrote:

> page.insert\_html :bottom, :product\_div, ‘test’
> 
> but got similar results. The div element with id “product\_div” gets  
> updated with:
> 
> try { new Insertion.Bottom(“product\_div”, “test”); } catch (e)  
> { alert(‘RJS error:\n\n’ + e.toString()); alert(‘new  
> Insertion.Bottom(“product\_div”, “test”);’); throw e

How are you invoking the ajax stuff ( ie are you using the :update  
option (if so, don’t)

Fred

---

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [July 2, 2008, 7:22pm UTC](https://www.ruby-forum.com/t/rjs-ajax-insert-html-problem/142029/3 "2008-07-02T19:22:24Z")

</div>

Frederick,

You’re a genius. Thanks, that was it.

On Jul 2, 11:18 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
