Same controller, two contexts return different request headers

I have one controller that has two routes. One is a "direct" route and
the other is a nested resource under another object. The two URLs are:

I have an AJAX form that submits data to a method via the GET method
and then renders a JS ERB template to execute some Javascript and
update a div. This works as expected with the nested route. However
the bare or "direct" route's request headers that are sent to
controller from the AJAX call are "text/html,application/xhtml
+xml,application/xml;q=0.9,*/*;q=0.8" vs the proper "*/*;q=0.5, text/
javascript, application/javascript, application/ecmascript,

I have tried different ways to force the client to send the request
headers as javascript:

- Setting data-type attribute to script in the form
- Setting the headers["Content-Type"] to "text/javascript;
charset=utf-8" in the controller
- Adding :format => :js in the URL path helper method

I know I have tried more but I cannot remember all that i have tried
in the last two days trying to figure this out. What is weird is how
the same code works for the nested route but does not work for the
bare version. I am using Rails 3.1.3 with Ruby 1.9.3p0.

Thanks for any help,

This is probably a problem with the request and not the response.
Rails will give you what you ask on headers. So if your AJAX call is
asking for html, it's giving HTML and not JS.

Check if you're really asking for javascript on the ajax call's
headers, and please post how you're making this calls.