hello guys, I'm trying to make a ajax request and return some data from my controller, but how I do it to call the JSON in my JS after the request ?
controller task def create @task = Task.create( :project_id => params[ :project_id ], :name => params[ :task ] ) if @task.valid? @return = { :task => @task.name, :project_id => @task.project_id } else @return = { :error => "Ocorreu um erro inesperado. Tente novamente." } end return ActiveSupport::JSON.encode( @return ) end view index - JS $( "#tasks_form" ).submit( function( e ) { e.preventDefault(); var task = $( this).find( "textarea" ).val(); $.post( "<%= url_for :controller => :task, :action => :create %>", { task: task, project_id: <%= @project_id %> }, function( e ) { }, "json"); } ); Thank you -- Posted via http://www.ruby-forum.com/. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.