Some time passed since this question was published, but I just took some time to figure it out and could not find too much help in this online mode, therefore:
The solution is to create .js.erb files - one for success and one for failure.
def create
@foo = Foo.new(params[:foo])
if @foo.save
respond_to do |format|
format.html { redirect_to root_path }
format.js { render :action => "success"}
end
else
respond_to do |format|
format.html { render :action => 'new'}
format.js { render :action => "failure"}
end
end
end
end
, , create.js.erb ( format.js create). /, - action.