Skip to content Skip to sidebar Skip to footer

Jquery, Ajax, Post Function, Rails

I am a Rails newbie and have a question about posting from ajax to a rails controller, and returning the data to javascript. I'm pretty unfamiliar with how this actually works, bu

Solution 1:

I assume you want to return the user. In this case i recommend:

def create
  @user = User.create( params[:tester] )
  respond_to do |format|
    format.html
    format.json  { render :json => @user}
  end
end

And then just make the ajax call request the json


Post a Comment for "Jquery, Ajax, Post Function, Rails"