ruby-on-rails - 在 Rails 上的 ajax 中传递文本字段值

标签 ruby-on-rails ajax

我正在使用

<%= text_field 'person', 'one',:id => 'test', :onchange=>remote_function(:url=>{:action=>"update"}, :update=>"test") %>
<div id="test"></div>

现在我只想用 :action 发送 text_field 的值 即 :url=>{:action=>"update(value_of_text_field_entered"}

不想使用 params[:person][:one]。

有什么建议吗?或者如何使用 <%=observe_field%> 通过操作发送值?

最佳答案

您也可以尝试这个:
<%= text_field 'person', 'one' %>


### Paste following code in your javascript

$("#person_one").live("change", function(){
  $.ajax({
    complete:function(request){},
    data:'person_one='+ $(this).val(),
    dataType:'script',
    type:'get',
    url: '/update'route
  })
});


关于ruby-on-rails - 在 Rails 上的 ajax 中传递文本字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2720867/

相关文章:

javascript - rails 5 : Get current URL and send back to backend

java - struts2中如何调用一个action中定义的不同方法?

javascript - AngularJS ng-select 和 ng-switch-when 问题

ajax - jQuery Masonry 和 Ajax-fetching append 项目导致图像重叠

css - 如何使用 active_link_to 将边框直接定位在事件链接上? rails 4

ruby-on-rails - rails : Copying attributes from an object to another using the "attributes" method

javascript - 来自 AmpersandJS 的跨源请求

javascript - 如何使用 dajax/dajax-ice 填充 div?

ruby-on-rails - 如何在 Rails 中设置 GraphQL Relay API

ruby-on-rails - 编码::UndefinedConversionError: "\xE4"从 ASCII-8BIT 到 UTF-8