Thursday, May 24, 2012

[Rails] Re: paramater passing with ajax in rails

Robert Walker wrote in post #1062048:
> You pass the parameter the same way you always do with HTTP. Put it in
> the query string or request body. JQuery makes this easy using the
> "data" attribute:
>
> $.ajax({
> type: 'PUT',
> url: url,
> data: data,
> success: success,
> dataType: dataType
> });
>
> data - A map or string that is sent to the server with the request.

I forgot one other possible location. The data/attribute could be part
of the URL itself, as is often the case with Rails routes (i.e.
http://localhost:3000/pgms/cpn_activate/1 #where 1 is the id).

P.S. That's a pretty ugly URL for a Rails app by the way. Maybe you
should consider cleaning that up. Start with not abbreviating so much.
If "pgms" means "programs" then have a Program model and
"/programs/:action/:id" for the route. Search engines will also
appreciate having actual words in the URL. The more clear the intent the
better. We're not in danger of running out of letters on the web.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate