转: http://www.alfajango.com/blog/rails-3-remote-links-and-forms/
<script type="text/javascript">
//处理ajax回调函数
$(function() {
// ajax:before // fires before the request starts, provided a URL was provided in href or action
// ajax:loading // fires after the AJAX request is created, but before it's sent
// ajax:success // fires after a response is received, provided the response was a 200 or 300 HTTP status code
// ajax:failure // fires after a response is received, if the response has a 400 or 500 HTTP status code
// ajax:complete // fires after ajax:success or ajax:failure
// ajax:after // fires after the request events are finished
$('#ajax_form').bind('ajax:success', function(evt, xhr, settings) {
alert(xhr.username);
alert(xhr.password);
});
});
</script>
<%= form_tag "/layer/ajax_form", :id=>'ajax_form', :remote=>true, :method =>:post do %>
<%= label_tag :username, '用户名' %>
<%= text_field_tag :username %>
<%= label_tag :password, '密码' %>
<%= password_field_tag :password %>
<%= submit_tag '提交请求' %>
<% end %>
<h1>改善下</h1>
<h3>
使用 url_for 查找Url
<%= url_for(:controller => 'layer', :action => 'ajax_form') %>
</h3>
<%= form_tag url_for(:controller => 'layer', :action => 'ajax_form'), :id=>'ajax_form_2', :remote=>true, :method => :post do %>
<%= label_tag :username, '用户名' %>
<%= text_field_tag :username %>
<%= label_tag :password, '密码' %>
<%= password_field_tag :password %>
<%= submit_tag '提交请求' %>
<% end %>
分享到:
相关推荐
关于ruby on rail的ajax,英文版
they have rail-to-rail input or output operation capability. While some amplifiers on the market are able to accept input voltages from one rail to the other rail, this is achieved with a few ...
你可以把它拖放到任何应用程序中,从而完成以下这些事情:确认对话框的各种操作从超链接获得 non-GET 请求使表格和超链接呈递的数据与 Ajax 的同步表单提交成功后,按钮自动关闭,以防止双击 标签:jQuery
这是国外的东西,Australian light rail report 全英文
Europe by Rail 东北大学数据结构实验
rail on ruby
o RailSystem.h - This declares a class to represent the rail system. o RailSystem.cpp - This is a partial implementation of class RailSystem. o services.txt - This file contains data that defines ...
服务器虚拟化系统InCloud Rail 6.0.0虚拟化架构系统。
将Ruby on Rail的基础知识汇集到一张纸上,超实用
Power-Rail LED照明解决方案pdf,Power-Rail LED照明解决方案
Power and Rail Analysis Using Encounter Power System
A Compact Power-Efficient 3 V CMOS Rail-to-Rail Input/Output Operational Amplifier for VLSI Cell Libraries
ruby是一种编程语言,本人接触大概几个月时间,由于本人比较笨,所以领会的不深,很肤浅。在这里希望与了解的人探讨一下 对于初学者来说,我觉得首先入门类书籍应该选择《programming ruby中文版 第2版》书里写的...
The Application of DIN Rail 3 Two-wire 4-20mA Isolation Transmitter/Isolator/Distributorpdf,The Application of DIN Rail 3 Two-wire 4-20mA Isolation Transmitter/Isolator/Distributor
[Ruby_on_Rails][中文]_03._[Windows]_安裝Ruby_on_Rail_6.x
SIMPack资料,含车体、转向架、轮对等各类模型。
根据[agile.web.development.with.rails]介绍的方法分离出的完整rails api 文档,html格式
Crosswind action on rail vehicles Wind tunnel experimental analyses
ruby,一种跨平台、面向对象的动态类型编程语言。Ruby 体现了表达的一致性和简单性,它不仅是一门编程语言,更是表达想法的一种简练方式。
轨对轨运算放大器的版图设计,rail to rail