might be obvious, but still i'm lacking here of basic knowledge. so inside controllers, can both be used, or is it always javascript, so both are the same ?
+1
A:
I believe that both can be used because they're separate MIME types. Why not try it and see?
John Topley
2010-02-25 17:22:59
+1
A:
json
and js
are two different types of response and they are defined as different MIME types in Rails
Mime::Type.register "text/javascript", :js, %w( application/javascript application/x-javascript )
Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest )
Even if Json can be considered a subset of JavaScript, not all JavaScript responses are actually JSon responses.
You might want to respond with Json and Js in the same action.
For instance, you might have an action that responds with Json to an API call and with JavaScript (perhaps using RJS) to an internal Ajax call.
Simone Carletti
2010-02-25 21:54:10