Forum: Ruby on Rails Ajax response not evaluating?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Baa493762803518bf4adfbeb75d98e76?d=identicon&s=25 Ilya Grigorik (Guest)
on 2007-04-02 01:16
This is an odd one. I just noticed that for some odd reason, my ajax
responses on 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", "<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});
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 - igvita.com/blog
Baa493762803518bf4adfbeb75d98e76?d=identicon&s=25 Ilya Grigorik (Guest)
on 2007-04-02 01: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.