Forum: Ruby on Rails RJS not sent as text/javascript

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.
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2006-04-23 20:50
(Received via mailing list)
I've made a couple of other posts about this and finally figured out
what was
wrong. For some reason, the RJS response was not being sent with a
content
type of "text/javascript" (which it should be, per the dox). The
following
line in each controller method that renders RJS makes my app work:

@headers['Content-Type'] = 'text/javascript'

Does anyone know why the content type might not be getting set
correctly?

Thanks
--
View this message in context:
http://www.nabble.com/RJS-not-sent-as-text-javascr...
Sent from the RubyOnRails Users forum at Nabble.com.
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-04-23 20:59
(Received via mailing list)
I think I encountered this problem when I rendered some partials to a
string.  That seems to set the content type, and subsequent renders
don't fix it.

On Sunday, April 23, 2006, at 11:46 AM, s.ross wrote:
>
>Thanks
>--
>View this message in context: http://www.nabble.com/
>RJS-not-sent-as-text-javascript-t1495574.html#a4053568
>Sent from the RubyOnRails Users forum at Nabble.com.
>
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails


_Kevin
D0cd6b10e01bacb976b3b815a9c660bc?d=identicon&s=25 Alex Wayne (Guest)
on 2006-04-23 21:15
Steve Ross wrote:
> I've made a couple of other posts about this and finally figured out
> what was
> wrong. For some reason, the RJS response was not being sent with a
> content
> type of "text/javascript" (which it should be, per the dox). The
> following
> line in each controller method that renders RJS makes my app work:
>
> @headers['Content-Type'] = 'text/javascript'
>
> Does anyone know why the content type might not be getting set
> correctly?
>
> Thanks
> --
> View this message in context:
> http://www.nabble.com/RJS-not-sent-as-text-javascr...
> Sent from the RubyOnRails Users forum at Nabble.com.

How exactly are you calling the rjs render?  Just a pass-through
(meaning no render statement)? using respond_to do |type|?

Either of those methods should pass the proper header.  Any other way of
doing it would probably send the default html header.
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2006-04-23 21:27
(Received via mailing list)
It's a pass-through and I'm at a loss to understand why the correct
header is
not being sent. I thought the :partial thing held some promise, but
reduced
it to render only the word 'hello, rjs' and that didn't work with me
explicitly setting the headers.
--
View this message in context:
http://www.nabble.com/RJS-not-sent-as-text-javascr...
Sent from the RubyOnRails Users forum at Nabble.com.
This topic is locked and can not be replied to.