How to remove POSTData?

S

sayoyo

Hi,

I write a simple form which have only one text field, I type somthing
inside the text filed, then click on a button, the controller retrieves
it from the @params['textone']. Everything works fine, however, when I
refresh the web page, it always ask to confirm the if I want to resend
the postdata, even there is nothing inside the text field.

Does someone know how to clean the POSTDATA or how to manage it.

Thanks you very much!!!!

sayoyo
 
J

James Britt

Hi,

I write a simple form which have only one text field, I type somthing
inside the text filed, then click on a button, the controller retrieves
it from the @params['textone']. Everything works fine, however, when I
refresh the web page, it always ask to confirm the if I want to resend
the postdata, even there is nothing inside the text field.

Does someone know how to clean the POSTDATA or how to manage it.

Don't refresh the browser. That just resends the POST request from the
previous page; it does not submit the current page.

James

--

http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools
 
G

gwtmp01

I write a simple form which have only one text field, I type somthing
inside the text filed, then click on a button, the controller
retrieves
it from the @params['textone']. Everything works fine, however, when I
refresh the web page, it always ask to confirm the if I want to resend
the postdata, even there is nothing inside the text field.

Perhaps the Post/Redirect/Get pattern can help you out:

http://www.theserverside.com/patterns/thread.tss?thread_id=20936

It sounds like you are running in a rails environment and someone more
knowledgeable than me about rails will have to comment on whether this
pattern can be (or already is) implemented by Rails.

The idea is that instead of responding with a page of content to a POST
request, the controller should respond with a Redirect (most likely to
itself). The redirect will cause the browser to issue a GET back to
the controller and the original POST request will *not* be saved in the
browsers history. If you do a page reload at this point you end up
reissuing the GET and not the original POST.



Gary Wright
 
R

Ryan Leavengood

It sounds like you are running in a rails environment and someone more
knowledgeable than me about rails will have to comment on whether this
pattern can be (or already is) implemented by Rails.

Not only is it implemented, but I'd say it is the default and
recommended pattern. See pages 309-311 of the "Agile Rails" book and
probably many, many examples of code online. I'd venture a guess this
is also in the online Rails documentation and/or wiki (though I
haven't taken the time to look.)

Ryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top