window.opener.location.reload(true) doesn't work?

Hi,

I have a popup that contains a form. When I submit that form, I need 1) the data to get saved into my database, 2) the popup to close, and 3) the parent window to refresh and display the updated data.

I found the following code in an old thread, but the parent window still shows the old data after it appears to reload. The data is saved in the database, but the parent window only shows the updated data when I manually refresh it by hitting F5.


<form action="process_form.php" method="post" onSubmit="window.opener.location.reload(true); window.close();">

Any idea why this doesn’t work?

TIA

I know why it doesn’t work.

Because first the parent frame is reloaded, and then the form is posted.
So the parent does not see the new data since it isn’t inserted yet.

I wouldn’t know from the top of my head how to solve this though …

Thanks ScallioXTX, I was wondering about the order of operations so to speak, so that helps. I’m trying to get it to submit the form then reload the parent then close, but this approach isn’t working either:


<script type='text/javascript'>
function submitform() {
document.myform.submit();
window.opener.location.reload(true);
self.close();
}
</script>



<form action="process_form.php" method="post" name="myform">
....
<input type='button' value='Submit' onClick="javascript: submitform()">

The form does submit but the parent doesn’t reload and the popup doesn’t close. If I comment out the form submit line, the parent does reload and the popup does close. Any insight is appreciated.

Has anything with the opener page changed prior to the call (such as the page having been previously reloaded)? If the page in the opener window changes in any way then the opener link between the two windows is broken.