I’m learning rails, while doing my app. So this is just the tip of the ice berg and I foresee many more questions in future.
I have the following setup.
Basically, on clicking the login button, a ajax request is sent, and the json response "message":"fail"
is returned.
My question is, how do I get the response in the success callback for processing? Here’s what I have at the moment.
index.html.erb
<h2>Log in</h2>
<%= form_for @user, :remote => true, :url => { :action => "login", :controller => "users" }, :html => { :class => "login" } do |f| %>
<%= label_tag(:password, "Password") %>
<%= f.text_field :password %>
<%= f.submit "Login" %>
<% end %>
home.js.coffee
$ ->
$('form').bind 'ajax:success', (result) -> console.log(result)
Output of console log
jQuery.Event {type: "ajax:success", timeStamp: 1353575112551, jQuery18209272595844231546: true, isTrigger: true, exclusive: undefined…}
I was actually expecting the console log output to be something like result[{ "message" : "fail"}]
?