Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果存在format.html,则响应_不使用format.js_Javascript_Ruby On Rails_Respond To - Fatal编程技术网

Javascript 如果存在format.html,则响应_不使用format.js

Javascript 如果存在format.html,则响应_不使用format.js,javascript,ruby-on-rails,respond-to,Javascript,Ruby On Rails,Respond To,使用respond\u to时,我的AJAX调用仅在HTML响应不存在时调用javascript响应 我有以下javascript用于提交就地编辑操作: $(".eip").editable("/surveys", { name : 'survey[name]', select : true, event : 'edit', submit : 'Save', cancel : 'cancel', cssclass : "editable", onblur : '

使用
respond\u to
时,我的AJAX调用仅在HTML响应不存在时调用javascript响应

我有以下javascript用于提交就地编辑操作:

$(".eip").editable("/surveys", {
  name   : 'survey[name]',
  select : true,
  event  : 'edit',
  submit : 'Save',
  cancel : 'cancel',
  cssclass : "editable",
  onblur : 'ignore',
  onedit : function() { $(".eip_desc").hide(); },
  onreset : function() { $(".eip_desc").show(); },
  onsubmit : function() { $(".eip_desc").show(); }
});
然后我有以下测量控制器方法:

class SurveysController < ApplicationController
  def create
    @survey = Survey.new(params[:survey])    

    if @survey.save
      respond_to do |format|
        format.html { redirect_to surveys_path, :notice => "Survey created!" }
        format.js
      end
    else
      render :action => :new
    end
  end
end
class SurveysController“Survey created!”}
format.js
结束
其他的
呈现:操作=>:新建
结束
结束
结束
如果我删除
format.html
行,那么
format.js
会按它应该的方式响应。但是如果我把
format.html
放在那里,那么当我通过
editable
javascript位提交时,整个页面都会呈现出来

我正在为此应用程序运行Rails 3.0.3。

来自文档

(字符串)方法:在 提交编辑内容。默认为 邮递您很可能想使用POST 或者放。PUT方法与 轨道


尝试传递一个方法:“put”

是正确的(主题外:但是put可以(以正确的方式)用于创建或更新。如果您知道如何命名资源,put可能是正确的coiche)。在这种情况下,可能是操作错误,必须通过更新操作来提供行内编辑。对不起,我的英语有问题吗?您正在编辑资源,对吗?