# AJAX request

**URL:** <https://www.ruby-forum.com/t/ajax-request/81049>\
**Category:** Rails\
**Created:** [January 3, 2007, 11:26am UTC](https://www.ruby-forum.com/t/ajax-request/81049 "2007-01-03T11:26:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![addywaddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@addywaddy](https://www.ruby-forum.com/u/addywaddy)\
**Post date:** [January 3, 2007, 11:26am UTC](https://www.ruby-forum.com/t/ajax-request/81049/1 "2007-01-03T11:26:59Z")

</div>

I’m having a bit of problem with my remote responses …

I’ve got this link:

\<%= link\_to\_remote(\_("\_add"),  
:url =\> {:controller =\> ‘versions’, :action =\> ‘new’, :project =\>  
@project, :id =\> @document},  
:loading =\> “Element.show(‘loader’)”,  
:complete =\> evaluate\_remote\_response) %\>

which calls this rjs file:

page[‘version\_form’].replace\_html :partial =\> “new”  
page.visual\_effect :slide\_down, :version\_form, :duration =\> 0.2  
page[‘loader’].hide

where the partial, ‘new’ is a form.

This works fine in safari and firefox but I just can’t get it working in  
ie (6&7). I’ve even tried commenting out the first 2 lines of the rjs  
file so that it reads:

page[‘loader’].hide

and nothing else but nope. My loader just stays on.

Any ideas?

Oh and Happy New Year by the way!

Regards

Adam

---

<div class="post-metadata">

**Author:** ![addywaddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@addywaddy](https://www.ruby-forum.com/u/addywaddy)\
**Post date:** [January 4, 2007, 2:57pm UTC](https://www.ruby-forum.com/t/ajax-request/81049/2 "2007-01-04T14:57:36Z")

</div>

Some additional info:

For some reason, the above works in IE 6 & 7 when I replace the .rjs  
with an inline rjs in the controller action.

And to make matters more confusing, I created a test rails app with  
similar code to the above and … it works in IE!

So this must be something specific to my application.

Any ideas?

---

<div class="post-metadata">

**Author:** ![addywaddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@addywaddy](https://www.ruby-forum.com/u/addywaddy)\
**Post date:** [January 4, 2007, 3:15pm UTC](https://www.ruby-forum.com/t/ajax-request/81049/3 "2007-01-04T15:15:12Z")

</div>

Adam G. wrote:

> Some additional info:
> 
> For some reason, the above works in IE 6 & 7 when I replace the .rjs  
> with an inline rjs in the controller action.
> 
> And to make matters more confusing, I created a test rails app with  
> similar code to the above and … it works in IE!
> 
> So this must be something specific to my application.
> 
> Any ideas?

So you’ve confirmed that the action gets hit (since the inline RJS  
works) ?

Firebug installed in Firefox would at least allow you to see whats was  
coming fdown the pipe.

Removing the evaluiate\_response and dumping the response text in an  
alert box might let you see the javascript in IE.

Alan

---

<div class="post-metadata">

**Author:** ![addywaddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@addywaddy](https://www.ruby-forum.com/u/addywaddy)\
**Post date:** [January 4, 2007, 3:36pm UTC](https://www.ruby-forum.com/t/ajax-request/81049/4 "2007-01-04T15:36:33Z")

</div>

Thanks for the reply Alan.

I think that with rjs, the :complete bit in a link\_to\_remote is  
superflous now. At least, it works without it. And changing to :complete  
=\> “alert(request.responseText)” doesn’t alter anything: it still  
executes in Safari & FF (and not in IE).

I’ve got firebug and that shows everything to be working as it should.  
The only thing I can think of is that for some reason, the response text  
from my rjs templates is not being interpretted by IE (poss wrong  
content type?).

I’ve also got this in my rhtml template for debugging purposes. In  
Safari and FF, it shows the request url and response text, but in IE it  
just shows the url.

I’m confused …

---

<div class="post-metadata">

**Author:** ![addywaddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@addywaddy](https://www.ruby-forum.com/u/addywaddy)\
**Post date:** [January 4, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/ajax-request/81049/5 "2007-01-04T16:23:24Z")

</div>

In case anyone’s interested - problem solved!

I’ve been developing this app for over a year now and forgot about this  
little before filter:

def configure\_charsets  
@headers[“Content-Type”] = “text/html; charset=utf8”  
end

Whoops!

Thanks anyway Alan for replying.

---

<div class="post-metadata">

**Author:** ![addywaddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@addywaddy](https://www.ruby-forum.com/u/addywaddy)\
**Post date:** [January 4, 2007, 3:52pm UTC](https://www.ruby-forum.com/t/ajax-request/81049/6 "2007-01-04T15:52:45Z")

</div>

I just said that firebug was showing everything to be ok but I checked  
the HEADERS tab in console and what do you know? … the content-type  
is text/html! In my test app, it’s text/javascript. Bizarre!

---

<div class="post-metadata">

**Author:** ![addywaddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@addywaddy](https://www.ruby-forum.com/u/addywaddy)\
**Post date:** [January 4, 2007, 5:18pm UTC](https://www.ruby-forum.com/t/ajax-request/81049/7 "2007-01-04T17:18:24Z")

</div>

Adam G. wrote:

> In case anyone’s interested - problem solved!
> 
> I’ve been developing this app for over a year now and forgot about this  
> little before filter:
> 
> def configure\_charsets  
> @headers[“Content-Type”] = “text/html; charset=utf8”  
> end
> 
> Whoops!
> 
> Thanks anyway Alan for replying.

🙂

Glad you got it sorted out. It still seems odd to me though, that you  
didn’t get the alert in IE. Even if it was being send with text/html,  
I’d have thought it wouldn’t evalutae\_response, but it _would_ have  
displayed the javascript.

Weird.

A.
