Stop rendering a response in the default layout

I am trying to follow this tutorial here by Ryan :

it is a AJAX tutorial on using jquery and expecting the response to be
in the form of javascript that will be acted upon by the browser.
however, i am getting the response to be rendered in the default
layout. i am getting the appropriate response but the js is embedded
in HTML and thus not execuuted. is there a way to turn the rendering
off for certaini cases?


Rails should really not use the layout unless it's an HTML request.
Let me ask you something: Did you accidentally call the view
create.html.erb instead of create.js.erb? Remember, the name of a view
is separated in three parts by dots: The first one is the name of your
action (in this case "create"), the second one is the format (in this
case it should be "js" to avoid embedding the output in the layout),
the third is the template language (in this case "erb" or embedded
Ruby, but it could also be "haml", "builder", "rjs" or whatever suits
the need of that specific view).

And then if you are sure that the view is correctly named: What
version of Rails do you use? You can find out by looking in your
environment.rb file.

here is the js that i am using for the request. does it not make a js

here is my controller:

then i am using create.js.erb for the response...

i am using rails 2.3.0.

here is specifically what i get in my firefox debug window:

syntax error
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n

Well, if you are sure that:

1) You have correctly named the view "create.js.erb"
2) You don't have a layout called something like "application.js.erb"

... I have really have no clue what's going on here. I suggest you try
to upgrade the application to the latest version of Rails, and if that
doesn't fix it, I'ld be more than happy if you zipped the app and
uploaded it somewhere, so I could take a closer look.

That's your problem right there - 2.3.0 (the first RC) had issues with
template handling on javascript requests. See these tickets:

Upgrading to 2.3.2 will fix this.

--Matt Jones