javascript - Is making POST requests with additional parameters via link_to acceptable? -


it's easy make link in rails make post request. link_to 'click me', some_path, :method => :post. works great... unless need pass additional parameters in. because there's no way make actual post request link, rails fakes request, means if try pass additional parameters some_path, builds query string. when mouseover link looks this:

/some_path?foo=var&foo=bar[foo][bar]

normally wouldn't bad, except gets ugly if you've got controller expecting nested params.

so question is, bother else, or me?

the workaround can think of change href #, add hidden form nearby, , add click handler link serializes form , submits when link clicked. makes link degrade ungracefully , awful lot of work amounts aesthetic gripe. i'm pretty obsessive urls. there easier way? or being crazy , should deal params in query string?

the web ugly place, , 1 of things that's annoying can't make link post without creating form or doing wild javascript handle in background.

it bothers people concerned how tidy urls are, concern far few have in honesty, reliable solution form plus tidy little jquery extension handle trigger.

to avoid seeing ugly url in browser, though, can make request via ajax, send url, redirect url once ajax part completed. gives opportunity present "submitting" or "requesting" type spinner.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -