【发布时间】:2010-09-05 07:42:24
【问题描述】:
所以我使用 form_remote_tag 来尝试提交 ajax 表单,如下所示:
<% form_remote_tag :update=> 'test', :url=> {:action=>'test_action'} do -%>
渲染没有明显问题:
<form action="/pages/test_action" method="post" onsubmit="new Ajax.Updater('test', '/pages/test_action', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">
test_action 动作:
def test_action
if request.xhr?
render :text => 'some text'
else
puts 'nope'
end
end
当我提交表单时(通过提交按钮,没有什么像 jquery submit() 事件那样奇怪),没有发出 ajax 请求。 xhr 检查返回 false。请帮忙??
【问题讨论】:
标签: ruby-on-rails ajax