# RJS not sent as text/javascript

**URL:** <https://www.ruby-forum.com/t/rjs-not-sent-as-text-javascript/94167>\
**Category:** Rails\
**Created:** [April 23, 2006, 8:50pm UTC](https://www.ruby-forum.com/t/rjs-not-sent-as-text-javascript/94167 "2006-04-23T20:50:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [April 23, 2006, 8:50pm UTC](https://www.ruby-forum.com/t/rjs-not-sent-as-text-javascript/94167/1 "2006-04-23T20:50:05Z")

</div>

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-javascript-t1495574.html#a4053568](http://www.nabble.com/RJS-not-sent-as-text-javascript-t1495574.html#a4053568)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [April 23, 2006, 8:59pm UTC](https://www.ruby-forum.com/t/rjs-not-sent-as-text-javascript/94167/2 "2006-04-23T20:59:23Z")

</div>

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/](http://www.nabble.com/)  
> RJS-not-sent-as-text-javascript-t1495574.html#a4053568  
> Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

\_Kevin

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [April 23, 2006, 9:15pm UTC](https://www.ruby-forum.com/t/rjs-not-sent-as-text-javascript/94167/3 "2006-04-23T21:15:19Z")

</div>

Steve R. 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-javascript-t1495574.html#a4053568](http://www.nabble.com/RJS-not-sent-as-text-javascript-t1495574.html#a4053568)  
> Sent from the RubyOnRails Users forum at [Nabble.com](http://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.

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [April 23, 2006, 9:27pm UTC](https://www.ruby-forum.com/t/rjs-not-sent-as-text-javascript/94167/4 "2006-04-23T21:27:41Z")

</div>

## 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-javascript-t1495574.html#a4054012](http://www.nabble.com/RJS-not-sent-as-text-javascript-t1495574.html#a4054012)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).
