0

我已经开始学习rails和javascript。我如何使用 jquery 向 Rails 控制器发出正确的 ajax 请求?我写在js文件中

$.get('http://localhost:3000/take/show',{},function(s){
           alert(s);
          },'text');

在控制器中:

class FirstController < ApplicationController
  def show 
    render :json => "Hi!"
  end
end

但相反,我只看到空白警报对话框。我做错了什么?在所有教程中,我看到 $.get 中的 URL 应该是这样的“take/show”,但在我的情况下它不起作用,那为什么呢?

4

0 回答 0