admin管理员组文章数量:1410712
http://localhost:3000/users?utf8=%E2%9C%93&search=aen
Here's my form in the view:
<% form_tag users_path, :method => 'get', :html => { :class => 'ui-form' } do %>
<div class="ui-input ui-input-search">
<%= text_field_tag :search %>
</div>
<% end %>
Which generates a hidden field that gets submitted:
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
http://localhost:3000/users?utf8=%E2%9C%93&search=aen
Here's my form in the view:
<% form_tag users_path, :method => 'get', :html => { :class => 'ui-form' } do %>
<div class="ui-input ui-input-search">
<%= text_field_tag :search %>
</div>
<% end %>
Which generates a hidden field that gets submitted:
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
Share
Improve this question
edited Apr 23, 2011 at 6:57
Bohdan
8,4187 gold badges43 silver badges54 bronze badges
asked Apr 23, 2011 at 6:38
Aen TanAen Tan
3,3456 gold badges35 silver badges53 bronze badges
1
- 1 look at his question stackoverflow./questions/3222013/… – Naren Sisodiya Commented Apr 23, 2011 at 7:20
4 Answers
Reset to default 6Set the disabled
attribute on the field you don't want to submit.
Or is the real question about how to get rails to not create that hidden field in the first place?
This can be done with JS if you use form.serialize() remove unnecessary part of parameters and make a new get request with new params
You can try doing something like this in an onsubmit
function:
document.getElementsByName('utf8')[0].disabled = "disabled";
to prevent it from being sent.
Here's a jquery snippet - add it to your layout to disable the utf8 field in all GET forms
:javascript
$('form[method=get] input[name=utf8]').attr("disabled", "disabled");
本文标签: javascriptDo not include hidden field in query string when submitting form with GETStack Overflow
版权声明:本文标题:javascript - Do not include hidden field in query string when submitting form with GET - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744793063a2625408.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论