【发布时间】:2014-08-11 18:31:21
【问题描述】:
我正在使用 ruby on rails 并尝试进行 ajax 调用,但一直看到错误。 所以在我的 index.html.erb 中,我有一个带有 id 测试的按钮。在同一个索引文件中,我有
("#test").click(function(){
$.ajax({
type: 'POST',
url: '/test',
data: {key: 'value'},
dataType: 'script',
});
});
所以,当我点击带有 id test 的按钮时,我一直看到
POST http://localhost:3000/test 404 (Not Found)
我似乎无法弄清楚为什么,因为在我的 config/routes.rb 中,我得到了 '/test',到:'prompts#test' 并且在我的 promptsController 中,我有
def test
puts "enters here"
end
【问题讨论】:
-
添加有问题的
rake routes的输出
标签: jquery ruby-on-rails ruby ajax