# Problem with ajax and textareas on firefox but works on IE

**URL:** <https://www.ruby-forum.com/t/problem-with-ajax-and-textareas-on-firefox-but-works-on-ie/79622>\
**Category:** Rails\
**Created:** [March 10, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/problem-with-ajax-and-textareas-on-firefox-but-works-on-ie/79622 "2006-03-10T20:25:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Teng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@Daniel\_Teng](https://www.ruby-forum.com/u/Daniel_Teng)\
**Post date:** [March 10, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/problem-with-ajax-and-textareas-on-firefox-but-works-on-ie/79622/1 "2006-03-10T20:25:08Z")

</div>

Hi folks,

I’ve been trying to figure this one out for a few hours now and can’t  
seem to understand what I might be doing wrong here. Basically, I have  
a textarea which has a little icon next to it which will fire off a  
reset of the original comment if pressed. It works under IE so that  
when the user types some garbase in to the textarea, and clicks the  
icon, the contents of the textarea resets; however, under firefox, i can  
see the ajax call hitting the server (the console shows it), but the  
text area doesn’t refresh.

I have the following textarea in my \_form.rhtml (and have the \<%=  
javascript\_include\_tag “prototype” %\> in the layout rhtml file.

  
\<%= text\_area ‘reviewcomment’, ‘safety’, ‘cols’ =\> 45, ‘rows’ =\>  
5 %\>  
  
  
\<%=  
link\_to\_remote(image\_tag("/images/UI/buttons/open\_review.gif"),:update  
=\> ‘reviewcomment\_safety’,:url =\> {:action =\> ‘resetComment’, :factor =\>  
‘Safety’, :rating =\> @reviewrating.safety}) %\>  

In my controller, the code looks like  
def resetComment  
@factor = params[:factor]  
@rating = params[:rating]  
@rt = Ratingtemplate.find(:first, :conditions=\> [“factor = ? AND  
rating = ?”, @factor, @rating])  
@comment = @rt.defaultcomment  
render(:layout =\> false)  
end

And finally, I have a resetComment.rhtml  
\<%= @comment %\>

Any help on this would be greatly appreciated!  
Daniel

---

<div class="post-metadata">

**Author:** ![Daniel\_Teng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@Daniel\_Teng](https://www.ruby-forum.com/u/Daniel_Teng)\
**Post date:** [March 10, 2006, 10:11pm UTC](https://www.ruby-forum.com/t/problem-with-ajax-and-textareas-on-firefox-but-works-on-ie/79622/2 "2006-03-10T22:11:10Z")

</div>

Daniel Teng wrote:

> And finally, I have a resetComment.rhtml  
> \<%= @comment %\>
> 
> Any help on this would be greatly appreciated!  
> Daniel

Doesn’t resetComment.rhtml need to be a partial? eg:  
\_resetComment.rhtml

---

<div class="post-metadata">

**Author:** ![Daniel\_Teng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@Daniel\_Teng](https://www.ruby-forum.com/u/Daniel_Teng)\
**Post date:** [March 10, 2006, 10:29pm UTC](https://www.ruby-forum.com/t/problem-with-ajax-and-textareas-on-firefox-but-works-on-ie/79622/3 "2006-03-10T22:29:45Z")

</div>

I tried changing that to \_resetComment.rhtml, but with no effect. I  
also assumed that in the controller, I had to do the follow?

render :=\>partial “resetComment”

In both cases, it did not seem to make a difference under firefox.  
Arghhhhh…

---

<div class="post-metadata">

**Author:** ![Daniel\_Teng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@Daniel\_Teng](https://www.ruby-forum.com/u/Daniel_Teng)\
**Post date:** [March 13, 2006, 6:24am UTC](https://www.ruby-forum.com/t/problem-with-ajax-and-textareas-on-firefox-but-works-on-ie/79622/4 "2006-03-13T06:24:04Z")

</div>

Thanks Tony,

I tried that and it seems to at least work the first time around  
now(didn’t work at all before). I wonder if I need to rename the file  
to \_resetComment.rhtml? It’s being included in the \_form.rhtml called  
by the edit action.

Daniel

---

<div class="post-metadata">

**Author:** ![Daniel\_Teng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@Daniel\_Teng](https://www.ruby-forum.com/u/Daniel_Teng)\
**Post date:** [March 11, 2006, 3:40am UTC](https://www.ruby-forum.com/t/problem-with-ajax-and-textareas-on-firefox-but-works-on-ie/79622/5 "2006-03-11T03:40:42Z")

</div>

Can you try \<%=h @comment %\> instead?  
Firefox is more strict sometimes on returned innerHTML, better escape it  
first.

Daniel Teng wrote:

> Hi folks,
> 
> I’ve been trying to figure this one out for a few hours now and can’t  
> seem to understand what I might be doing wrong here. Basically, I have  
> a textarea which has a little icon next to it which will fire off a  
> reset of the original comment if pressed. It works under IE so that  
> when the user types some garbase in to the textarea, and clicks the  
> icon, the contents of the textarea resets; however, under firefox, i can  
> see the ajax call hitting the server (the console shows it), but the  
> text area doesn’t refresh.
