English 中文(简体)
铁路运输公司在406名回归者中未被接受,但只是在第二次申请后才被接受。
原标题:Rails ajax form on Firefox returns 406 not accepted - but only on second post request

使用铁路的Im为3.2.3,我有以下表格:

<%= form_for(@item, url: list_path, remote: true, html: {id: "item-create-form", class: "form-horizontal"}) do |f| %>
    <div class="input-append">
        <%= f.text_field :description, id: "item-description-input", autofocus: true, placeholder: "Type and press enter." %>
    </div>
<% end %>

采取下列行动:

def create
  @user = User.find_by_username(params[:username])
  @item = current_user.items.build(params[:item])
  respond_to do |format|
    if @item.save
      @item.update_attribute(:vpos, 0)
      @items = Item.find_all_by_user_id(@user)
      @items.each do |item|
        item.update_attribute(:vpos, item.vpos + 1)
      end
      format.js
    else
      format.js {render "errors" }
    end
  end
end

相应的j.erb案有,并按预期提交。 该法典:

$( #position-zero ).after( <%= escape_javascript(render(:partial => @item)) %> );
$( #item-create-form ).html( <%= escape_javascript(render(:partial => "item_create_form", :locals => { :@item => Item.new })) %> );
$("#item-description-input").focus();
$(".best_in_place").best_in_place();

我的申请。

//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require jquery.purr
//= require best_in_place
//= require_tree .
// Loads all Bootstrap javascripts
//= require bootstrap

一切都对“ Chrome”和“Sato”做了大量工作,只有《吉大港山区行动计划》200份答复。

然而,在第1版材料中,第1版是ok。 但是,第二版给我一个<代码>406未被接受错误。

在消防局的检查中,内容类型为:text/javascript,涉及第一项要求,但修改了text/html

我尝试在格式之后确定内容类型。 js(如:{ 提供内容-类型:案文/javascript },并在控制器上设定标题(如headers[“Content-Type”] = “text/javascript; charset=utf-8”)。

在那里发现的任何美好灵魂,都能够揭示这一令人痛心的问题。

最佳回答

notice the second line in ur js.erb? you are adding a form inside the form. so basically when u submit the form the second time, the first form is sent as the ajax request, however, the form above it is not, giving you the problem. you should remove that second line and things should be ok

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签