Ajax response not evaluating?


#1

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”, “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 - igvita.com/blog


#2

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

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?