Welcome to WebmasterWorld Guest from 50.16.112.199

Forum Moderators: coopster & jatar k

How to avoid resending form data on page refresh

   
7:31 am on Apr 29, 2011 (gmt 0)

5+ Year Member



Hi,
I realize that if i click on the refresh button of the browser after having submitted post data it is asking if i want to resend data again. Same if i click on the back button.

I am using the POST method
How can I avoid this?

Thank you in advance
2:51 pm on Apr 29, 2011 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



You avoid this by having the form processing page (the "action" page) redirect to a display page once it is finished processing the submitted data. That way if the page is refreshed, it's the display page and not the processing page that gets refreshed. Unfortunately, if they hit back twice they will still get to submit the data again. This cannot be prevented, however, you can check server-side if they are submitting the same data a second time and prevent it.
9:07 pm on Apr 29, 2011 (gmt 0)

5+ Year Member



could submit using ajax? or submit to a page that replies with a 204 status (doesnt change the page), or make the server side script detect duplicates.
11:43 pm on Apr 29, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Sometimes it is useful to be able to resubmit the form, especially when you have just been presented with a page containing an error message like: Network Timeout! The page you requested failed to return a response in a suitable time. or Transfer interrupted! The page you requested failed to respond.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month