?
Solved

Avoid Repot of data on refresh

Posted on 2006-06-14
11
Medium Priority
?
1,656 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 1200 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 800 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
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

752 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