Solved

Avoid Repot of data on refresh

Posted on 2006-06-14
11
1,655 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
Technology Partners: 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!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to count occurrences of each item in an array.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

726 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