Solved

Avoid Repot of data on refresh

Posted on 2006-06-14
11
1,654 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

733 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