Solved

Avoid Repot of data on refresh

Posted on 2006-06-14
11
1,648 Views
Last Modified: 2008-01-09
I've poked around and found some sense of what I can do to prevent the issue, but not for my situation.

I have a page with a form on it as well as links to some child pop-up windows.  Opening one of the child pop-ups takes you to an edit form that when submited displays a "Thank you, this page will close in 5 seconds" and then refreshes the Parent window via this function in the child popup
function closeIt(){
       opener.window.location.reload(true);
     setTimeout('JavaScript:window.close()',5000);
}
The problem arises when the user has submited some changes on the parent form first.  Then goes to a child popup, submits the edit form, then the child refreshes the parent and the "Do you want to repost Retry/ignore" window pops up for the parent.  Any ideas how I can make the parent not repost when I refresh it from the child?  I'm working with asp pages that also have some JS in it.
0
Comment
Question by:Nick_Chvr
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 16

Expert Comment

by:OliWarner
ID: 16908953
Yeah one easy way is to send the browser to the same page... That's like loading it again rather than refreshing... if you see what I mean...

In physical representation, that's like clicking the "go" button instead of clicking the refresh button.

I'll just dig up some code for you
0
 
LVL 10

Accepted Solution

by:
ClickCentric earned 300 total points
ID: 16908955
Hmm...not sure if this will work, but I *think* you can redirect the parent window to itself, ie the same address it's currently pointing to.  This would be the same as clicking on the address bar and pressing enter as opposed to refreshing or reloading the page.

Try:

function closeIt(){
      opener.window.location.href = opener.window.location.href;
     setTimeout('JavaScript:window.close()',5000);
}

I can't test it at the moment, but I think it would work.
0
 
LVL 16

Assisted Solution

by:OliWarner
OliWarner earned 200 total points
ID: 16908960
location.href=location.href;

That seems a little easy to me... so I'll just test it and get back to you
0
 
LVL 16

Expert Comment

by:OliWarner
ID: 16908965
Yes that seems to be working here but I havent tested it after a postback...
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16908989
I should mention there's at least one caveat to the method I mentioned that must be considered...if the page has updated itself relative to information that was posted to it, that information would be lost unless it's reposted, so the page loaded would be the original, unmodified page.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 16

Expert Comment

by:OliWarner
ID: 16909033
The only real way to avoid that is to force the submission of the form with a special value saying the the user didnt click the the submit button and so your system knows not to action the data but reouput it in the form fields...

Its all a bit nasty but I'm not entirely sure what you're trying to achieve by reloading the form anyway.
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16909043
I was thinking the same.
0
 
LVL 8

Expert Comment

by:netmunky
ID: 16911986
i often avoid reposting a form with refresh by having the form submit then do a header("Location: /whatever.php");

ie - usersubmit.php:
<?
if($_REQUEST['act'] == submit)
{
  dostuff();
  header("Location /usersubmit.php");
}
?>
<form action="/usersubmit.php">
<input type="hidden" id="act" name="act" value="submit">
...
</form>

this way the last action was a GET request, which does not ask to re-post data if a refresh is called.
0
 
LVL 2

Author Comment

by:Nick_Chvr
ID: 16922486
good posts, let me try some today
0
 
LVL 2

Author Comment

by:Nick_Chvr
ID: 16923133
Click Centric's suggestion was spot on.  Refreshes the page w/o a refresh. Oli Warner thanks for your help as well
0
 
LVL 2

Author Comment

by:Nick_Chvr
ID: 16923137
Edit:Refreshes the page w/o a repost
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video teaches users how to migrate an existing Wordpress website to a new domain.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now