我创建了一个测验。并使用 ajax 请求每页更改一个问题,我使用单选按钮回答,但是当我使用:with parameter 'answer='+$('answer').value .. link_to_remote 自身不响应它在同一页面中.
<div class = "y">
<% form_for @answer do |f|%>
<div class = "label_field_pair">
<label for "questions">
<%= @ans.ques %>
</label>
</div> <br>
<div class = "label_field_pair2">
<label for "options">
<div id = "option-1">
<%= radio_button_tag 'answer', 'ans1'%><%= @ans.ans1 %>
</div><br>
<div id = "option-2">
<%= radio_button_tag 'answer', 'ans2'%><%= @ans.ans2 %>
</div><br>
<div id = "option-3">
<%= radio_button_tag 'answer', 'ans3'%><%= @ans.ans3 %>
</div><br>
<div id = "option-4">
<%= radio_button_tag 'answer', 'ans4'%><%= @ans.ans4 %>
</div><br>
</label>
</div>
<div class="next">
<%= link_to_remote "Next",
:before => "Element.show('loader')",
:success => "Element.hide('loader')",
:url=>{:controller=>"answers", :action=>"next"},
:with => "'answer='+$('answer').value"
%>
</div>
<% end %>
</div>
当我不使用该答案时:它可以正常工作,任何人都可以帮助我。提前致谢。