Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Stop new request on page refresh  RSS feed

 
pawan chopra
Ranch Hand
Posts: 419
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a page where user can create a project online. I have project name and due date in the form. Once user clicks on the create project button on the server side I am checking that projects name already exist or not. If it exist I am sending an error to the User on the same page. Suppose user refresh that page it asks him to send the request again or not if user clicks ok another request . I want to stop that can any body tel me any way.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't stop the user request but you can keep track of which page he is looking at and change the way the repeated request is handled.

Bill
 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use Token to prevent double posting.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this article, paying particularly close attention to the PRG pattern.
 
Alpesh Padra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Syncronize Token Pattern for duplicate submit.
 
pawan chopra
Ranch Hand
Posts: 419
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:You can't stop the user request but you can keep track of which page he is looking at and change the way the repeated request is handled.

Bill


Thanks.
 
Manan Panchal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have some confusion.

Suppose, one page with "login" link on it.

We press the link and (1) GET request sent and server responded with login page.
We fill the form and press login button and (2) POST request sent, and if login will successful then server redirects a page with some user information with (3) GET request.

So, here request history like this according to number (1) GET, (2) POST, (3) GET.
Now, we press "Back" of browser, then why do browser sent (1) GET? why not (2) POST.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!