I'm trying to refresh a page without sending POST from the previous time.
I've tried
window.open("postme.php?r=t", "_self");
Which appends a ?r=t
to the end but it doesn't appear to refresh the page as the page displays a number of files in a directory which hasn't change even though I have moved or deleted them.
Can you specify the URL in window.location.reload();
?
Any ideas?
Thanks
I'm trying to refresh a page without sending POST from the previous time.
I've tried
window.open("postme.php?r=t", "_self");
Which appends a ?r=t
to the end but it doesn't appear to refresh the page as the page displays a number of files in a directory which hasn't change even though I have moved or deleted them.
Can you specify the URL in window.location.reload();
?
Any ideas?
Thanks
Share Improve this question edited Oct 31, 2013 at 23:36 George Brighton 5,1519 gold badges29 silver badges36 bronze badges asked Jul 2, 2009 at 10:18 thegunnerthegunner 7,16333 gold badges97 silver badges144 bronze badges6 Answers
Reset to default 6If you want to avoid having refresh reporting data (for any reason, including the user clicking the reload button) then use the POST-REDIRECT-GET pattern.
Redirect the user to the same page after you're finished using their POST data.
$URI = $_SERVER['REQUEST_URI'];
if(!empty($_POST)){
//magic
header("location:$URI");
}
Now when you refresh, it won't have POST data to resubmit.
Well.. late too I suppose, but then it could help someone. I used :
window.location.href = window.location.href;
In replacement of location.reload(); this will refresh the page without prompting user to resend information.
i know this is way late, and hope it applies: i had the same problem where when someone is confirming their inventory selection, it then emails the order [or subtracts from inventory database] then displays their order. then if they refresh, it resubmits the data. so i added a session_destroy(). but then when they refresh, there're lots of errors.
SO - i divided the code into [a]email the order/subtract from the inventory database, then [b]used a javascript "document.location.href='nextPage.php'" because i sometimes have problems using PHP's "location(nextpage.php)". anyway, it emails the info, then goes to the page that displays it. then one can refresh all they want and all that happens is it displays over and over.
hope that helps!
You could try:
window.location.reload(true); //true sets request type to GET
Got this to work...
window.location = "postme.php?r=t";