Forum: Ruby on Rails Ajax response not evaluating?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ilya G. (Guest)
on 2007-04-02 03:16
This is an odd one. I just noticed that for some odd reason, my ajax
responses on (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", "<b>Join the conversation!</b> To save
tutorials, <b><a href=\"/login\">login</a></b> or <b><a
href=\"/register\">register</a></b> for free. <a href=\"#\"
onClick=\"removeParent(this);\"><img src=\"/images/close.gif\"></a>");
new Effect.Appear("message-1411",{duration:1.5});

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 G. (Guest)
on 2007-04-02 03:40
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?
This topic is locked and can not be replied to.