# Ajax response not evaluating?

**URL:** <https://www.ruby-forum.com/t/ajax-response-not-evaluating/90816>\
**Category:** Rails\
**Created:** [April 2, 2007, 1:16am UTC](https://www.ruby-forum.com/t/ajax-response-not-evaluating/90816 "2007-04-02T01:16:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![igrigorik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e68b1a/32.png) [@igrigorik](https://www.ruby-forum.com/u/igrigorik)\
**Post date:** [April 2, 2007, 1:16am UTC](https://www.ruby-forum.com/t/ajax-response-not-evaluating/90816/1 "2007-04-02T01:16:54Z")

</div>

This is an odd one. I just noticed that for some odd reason, my ajax  
responses on [graphics-world.com](http://graphics-world.com) (rate a tutorial, report a tutorial,  
etc.) are not being evaluated. To make the puzzle even more interesting,  
it does work fine when a user is logged in!

Looking at the request/response cycle in Firebug, everything is fine.  
Here is a sample response for non-logged in user:

Element.update(“message-1411”, “ **Join the conversation!** To save  
tutorials, **\<a href="/login"\>login** or **\<a  
href="/register"\>register** for free. \<a href="#"  
onClick="removeParent(this);"\>\<img src="/images/close.gif"\>”);  
new Effect.Appear(“message-1411”,{duration:1.5});  
Element.hide(“t-1411-indicator”);

Now, I can stick this code into my console and run it… and it will  
perform all correct actions with no failures! Even better, the response  
is identical for a logged in user (which does evaluate). This pattern  
repeats on FF 1.5/IE 7.

I’ve updated all js scripts to latest revisions (rake rails:update…).

Any ideas? Can you give it a shot, do you see the same problem?

Ilya - [Ilya Grigorik](http://igvita.com/blog)

---

<div class="post-metadata">

**Author:** ![igrigorik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e68b1a/32.png) [@igrigorik](https://www.ruby-forum.com/u/igrigorik)\
**Post date:** [April 2, 2007, 1:40am UTC](https://www.ruby-forum.com/t/ajax-response-not-evaluating/90816/2 "2007-04-02T01:40:21Z")

</div>

As usual, you find the culprit right after you post a question. 🙂

The headers were sent as text/html, and explicitly forcing them to  
‘text/javascript’ did the trick:

return render(:controller =\> ‘/lists’, :action =\> ‘save.rjs’,  
:content\_type =\> “text/javascript; charset=utf-8”) if request.xhr?
