MKK
MKK

Reputation: 2753

How can I avoid "Are you sure you want to send a form again?"?

In my app

user can access to the community page just like this
http://example.com/communities?tag=lovely

then if I try to go back to the previous page. I always get this message

Are you sure you want to send a form again

This only appears when it's accessed from Safari

How can I avoid that. I don't want user to see it every time when they go back.

routes.rb

resources :communities

Upvotes: 2

Views: 3868

Answers (2)

Rosch
Rosch

Reputation: 1

just add

window.location.replace("about:blank");

Upvotes: -1

AlexChaffee
AlexChaffee

Reputation: 8252

One way to avoid this problem is to make your POST responses return a redirect (HTTP 301 or 303) to a new page, which the browser then requests with GET. Going back should (though doesn't always) fetch the original form page, not the POST.

In Rails, this run-around often looks like this:

  1. client GETs /foos/new
  2. server returns HTML with <FORM method='POST' action='/foos'>
  3. client POSTs /foos (with params)
  4. server creates a new Foo with id 123
  5. server returns redirect to /foos/123
  6. client GETs /foos/123
  7. server returns HTML for newly created Foo

Upvotes: 2

Related Questions