contact subscribe

Eliminating the 'resend POSTDATA' error.

Web browsers cache the data you POST through a web form. If you submit a form, continue browsing, and then hit the BACK button to a page dependent on POSTed information, a dialog box sometimes appears warning of the following:

The page cannot be refreshed without resending the information [POSTDATA]. Click Retry to send the information again or click Cancel to return to the page that you were trying to view.

The Problem

9 times out of 10, your average user will click 'OK'! Such a resend potentially creates a duplicate of the information submitted. For example, a user could unintentionally send an email twice, or post the same comment to a page twice. Or something much worse.

The Solution

The easiest way to prevent this problem is to POST to a different page (URI) than the one displaying the original form.

In a programming framework like Rails or Mojavi, however, it is sometimes desirable to POST a form to the same URI. The above "resend problem" usually occurs in such a situation, as the web browser rightfully assumes the page depends on the POSTed information.

The solution? Once your program has processed the submitted information, Send an HTTP 302 Redirect to the same URI. In Rails, this is done with redirect_to; in Mojavi, $controller->redirect(). Or Ruby's equivalent cgi.header() and PHP's header() functions.

Post Your Comment




Remember Me?