0
所以我使用的是form_remote_tag尝试一个ajax表单提交,就像这样: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 action:
def test_action
if request.xhr?
render :text => 'some text'
else
puts 'nope'
end
end
当我提交表单(通过提交按钮,没有什么奇怪的像jquery submit()e没有ajax请求。 xhr检查返回false。请帮助??
不应该request.xhr?至少返回true?那个动作就是我用来测试ajax请求是否被发送的东西。 – herpderp 2010-09-05 20:46:52