Hi, Got a question about how the book suggests sending POST requests using a form whenever one intents to change some database state. So I converted a bunch of links to forms which ended up creating buttons. I was wondering if there was a way to keep them links rather than buttons but still use POST in a form? thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060509/d9b67e96/attachment-0001.html
Am 10.05.2006 um 00:11 schrieb Sam Donaldson:> Hi, > > Got a question about how the book suggests sending POST requests > using a form whenever one intents to change some database state. > So I converted a bunch of links to forms which ended up creating > buttons. I was wondering if there was a way to keep them links > rather than buttons but still use POST in a form?Call a JavaScript that does an XmlHttpRequest (aka AJAX request) which is submitted via POST. *m
Manuel Holtgrewe <purestorm@...> writes:> > > Am 10.05.2006 um 00:11 schrieb Sam Donaldson: > > > Hi, > > > > Got a question about how the book suggests sending POST requests > > using a form whenever one intents to change some database state. > > So I converted a bunch of links to forms which ended up creating > > buttons. I was wondering if there was a way to keep them links > > rather than buttons but still use POST in a form? > > Call a JavaScript that does an XmlHttpRequest (aka AJAX request) > which is submitted via POST. > > *m >Or easier, your link should look like this: <a href=''document.forms[0].submit();''>Link Name</a> This submits the first form on the page. You can also specify forms by name or id I think, but you typically only have one form per page anyway.
Sam Donaldson wrote:> Hi, > > Got a question about how the book suggests sending POST requests using > a form whenever one intents to change some database state. So I > converted a bunch of links to forms which ended up creating buttons. > I was wondering if there was a way to keep them links rather than > buttons but still use POST in a form?Try link_to("Destroy!", {:action => ''destroy''}, :post => true). This will automagically create the javascript to turn the link in to a POST method.