Created
January 10, 2013 00:31
-
-
Save yoshifumi0521/4498330 to your computer and use it in GitHub Desktop.
RailsでのAjax処理。非同期通信をして、クライアントでにコールバックする。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// view/member/index.html.erb | |
<%= form_for @member,:remote => true,:html => {:id => 'form'} do |form| %> | |
//フォーム | |
<%= form.submit "送信" %> | |
<% end %> | |
<scritp> | |
$(function(){ | |
//Ajax処理 | |
$("#form"). | |
.live("ajax:beforeSend", function(e,data,status,xhr){ | |
//ajax通信の送信時の処理 | |
} | |
.live("ajax:success", function(e,data,status,xhr){ | |
//ajax通信の成功時の処理 | |
} | |
.live("ajax:error", function(e,data,status,xhr){ | |
// ajax通信失敗時の処理 | |
} | |
.live("ajax:complete", function(e,xhr,status){ | |
// ajax通信完了時の処理 | |
} | |
} | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment