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"}]?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/nQ0T4iEwIH4J.
For more options, visit https://groups.google.com/groups/opt_out.