Rails 关于 Rails 中的 Ajax

ecloud · March 01, 2018 · Last by ecloud replied at March 02, 2018 · 1522 hits

我在模版中写了一个发送 Ajax 的链接

<%= link_to 'Destroy', user_path(@user), method: :delete, remote: true %>

然后 coffee 中这样写的

$("a[data-remote]").on "ajax:success", (e, data, status, xhr) ->
        console.log e["detail"][0]

我在 coffee 代码中打印的 data, status 和 xhr 都是 undefined,要获取服务器返回的 json 只能通过 e["detail"][0],请问还有其他方式更方便的获取返回的数据吗?

服务器返回什么不是可以通过修改对应的 controller action 调整么?

ecloud closed this topic. 02 Mar 09:46
You need to Sign in before reply, if you don't have an account, please Sign up first.