【发布时间】:2014-04-09 12:06:17
【问题描述】:
在我的 Rails 应用程序中,我有这段代码
<a data-remote="true" href="#" class: "find_product">Find product</a>
对于 ajax 调用,我正在这样做
$(document).on('click', '.find_product', function(){
$.ajax({
url: "<%= startup_wizard_find_horse_path() %>",
dataType: 'script',
type: 'GET',
data: { box_no: "3"}
});
return false;
});
现在当我点击上面的链接时,ajax调用是发送到当前页面的action而不是
startup_wizard_find_horse_path
为什么会发生这种情况,我怎样才能做到这一点?
【问题讨论】:
-
我可能不知道 Rails,所以冒着被鞭打的风险:WTF 是
class: "find_product"? -
还有一件事,如果你想避免长时间拉扯头发,请学会使用 Network Tab
标签: jquery ruby-on-rails ajax