Rails远程调用无法在Firefox中运行

Joh*_*itt 11 ajax ruby-on-rails

以下链接在Chrome和Edge中运行良好,但在Firefox和IE中则不行.检查两者的网络图表显示未发送请求.将鼠标悬停在Chrome和Edge中的链接上会在文本下方显示下划线,并在页面底部显示目标.Firefox和IE没有显示这些,因此IE和Firefox似乎不认识这是一个链接

<a data-remote="true" rel="nofollow" data-method="post" href="/fetch_data?macaddress=ACB3131B6445&time=hour">Hour</a>
Run Code Online (Sandbox Code Playgroud)

生成链接:

<%= link_to "Hour", fetch_data_path(time: "hour", macaddress: @macaddress.to_s), method: :post, :remote => true %>
Run Code Online (Sandbox Code Playgroud)

编辑:Jquery版本是最新版本3.1.

application.js中:

//= require jquery3
//= require jquery_ujs
//= require_tree .
Run Code Online (Sandbox Code Playgroud)

Joh*_*itt 1

原来是我的懒惰造成的。

我最初错误地制作了按钮,这样它们只有在单击链接文本时才起作用,而不是整个按钮作为按钮工作:

<button class="btn btn-default" type="button">
    <%= link_to "Day", fetch_data_path(time: "day", macaddress: @macaddress.to_s), method: :post, :remote => true %>
</button>
Run Code Online (Sandbox Code Playgroud)

最后决定我应该解决这个问题,重新创建链接后,它在 Firefox 中工作正常:

<%= link_to fetch_data_path(time: "day", macaddress: @macaddress.to_s), method: :post, :remote => true do %>
    <div class="btn btn-default" type="button">Day</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)