How to make a respond_to by AJAX in Rails 3?



我有一个表单,使用AJAX发送。表单在FirstsController中。我需要把表格发给SecondsController。发送表单并保存数据。然后我想通过文本更改表单,我尝试通过这种方式:

  def create
   ...saving...
    respond_to do |format|
      format.js { 
        render :update do |page|; page << "$('#id_element').html('hellllloooooo');" end  
       }
      format.html {} 
    end
  end

我得到了这个错误:

ActionView::MissingTemplate (Missing template seconds/update, application/update with {:handlers=>[:erb, :builder, :coffee], :formats=>[:js, :html], :locale=>[:en, :en]}.):

我应该如何将JS请求设置回FirstsController?+需要任何帮助*.js文件吗?

这是正确的设置:

 def create
   ...saving...
    respond_to do |format|
      format.js { 
        render 'firsts/action_that_you_want' 
       }
      format.html {} 
    end
  end

并且在CCD_ 4中需要已经创建了文件CCD_。

最新更新