Click to See Complete Forum and Search --> : Reload Page without POSTDATA


nudave04
05-09-2004, 11:58 AM
I have a page that I need to reload from a popup.

Sometimes, this page is loaded with POST data, and sometimes it is not. So, on the reload, sometimes I get asked if I want to resubmit the postdata.

At the point where I will be doing the reload, the POST data is no longer relevant, so I would like some javascript code to automatically refresh the page without any postdata.

Any suggestions?

Michael2003
05-09-2004, 12:41 PM
<script type="text/javascript">
window.location=window.location;
</script>
That should do the trick as long as it is only outputted when there is post data (I am assuming that you have server side stuff going on so that would be possible.

However, if you already have server-side stuff why not keep it server-side and do something like:

<?php
header("Location: http://thesite.com/page.php");
?>
When there is post data to remove the need for JS to do the job at all, and give you time to process the data.

nudave04
05-09-2004, 12:51 PM
I had code similar to your javascript code, and it works to refresh the page when there is postdata... but sometimes i want to refresh the page when there is no postdata. The page i'm workign on has a few form elements, and the postdata from some is irrelevant by the time I want to do this reload.

I tried an if statement to the effect of:

if (window.location.href == 'SITE ADDRESS') {
window.location.reload(true);
} else {
window.location = 'SITE ADDRESS'
}

But that only worked when there was no postdata... i need it to work regardless of whether there is postdata