-1
我有一个问题,在铁轨我Ajax调用,当我使用的form_tag或的form_for发送Ajax调用的form_tag在轨
我的form_tag的样子:
` <%= form_tag(type_name_Tous_path, :method => "get") do %>
<%= text_field_tag :key,params[:key]" %>
<%= text_field_tag :lieu,params[:lieu]" %>
<%= select_tag :nom, options_from_collection_for_select(TypeName.all, :id, :nom, params[:nom]),id:"select_categori"%></span>
<button id="input_btn"><%= submit_tag "Chercher"%></button>
<ul id="sous_select">
<% @tag %>
</ul>
<% end %>`
我Ajax调用的样子:
` $(function(){
$(".selectable").selectable({
selected: function(event, ui){
var selected=$("li[class$='ui-selected']").val();
$('#input_btn').click(function(){
alert(selected);
if(selected != null){
$.ajax({
url:'/type_name/Tous',
type:'Get',
data:{my_ta:selected},
success:function(data){
alert(data)
},
error:function(data){
alert("erreur"+data)
}
})
}else{
console.log('pas de selection proposé')
}})}});});`
而在我的控制器中,当我做出了“ok ok#{params [:my_ta]}”我有两个答案,第一个答案很好,例如“ok ok 9”,第二个答案后就像“好吧”,这是因为我c所有两次type_name路由?
感谢您的答复,我尝试您的建议,但它不起作用,你有其他选择吗? –
是否有任何工作? 您可以将您的路线连接到控制器吗? 而您需要将标签更改为(作为示例)f.text_field。你知道怎么做吗? –