form :remote => true, submitted twice in IE

六月ゝ 毕业季﹏ 提交于 2020-01-06 08:58:10

问题


I have a form tag with like following:

      <%= form_tag(new_invitations_invitations_path, :remote => true) do %>
        <%= hidden_field_tag(:provider, "yahoo") %>
        <dl>
          <dt><strong>Your email:</strong></dt>
          <dd><%= text_field_tag('email') %></dd>
        </dl>
        <dl>
          <dt><strong>Password:</strong></dt>
          <dd><%= password_field_tag('pass') %></dd>
        </dl>
        <dl>
          <dt>&nbsp;</dt>
          <dd><%= submit_tag "Import your address book", :disable_with => "Please wait..." %></dd>
        </dl>
      <% end %>

Above gives output HTML as following:

<form accept-charset="UTF-8" action="/invitations/new_invitations" data-remote="true" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="EC+HcCqnxadujZg8CMWHGT1blQ3KoIddlnR8teWaowQ=" /></div>
  <input id="provider" name="provider" type="hidden" value="yahoo" />
  <dl>
    <dt><strong>Your email:</strong></dt>
    <dd><input id="email" name="email" type="text" /></dd>
  </dl>
  <dl>
    <dt><strong>Password:</strong></dt>
    <dd><input id="pass" name="pass" type="password" /></dd>
  </dl>
  <dl>
    <dt>&nbsp;</dt>
    <dd><input data-disable-with="Please wait..." name="commit" type="submit" value="Import your address book" /></dd>
  </dl>

When I try to submit above form in IE by pressing the submit button, the form is submitted twice. The problem is that once it is submitted with format as JS which is correct. And once it is submitted as HTML which is wrong. Because of second submission, I get a 406 not acceptable error.

Any clues?


回答1:


It turns out to be that I had older versions on Prototype and rails.js in my application. Upgrading solved the problem.



来源:https://stackoverflow.com/questions/6925415/form-remote-true-submitted-twice-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!