Javascript interaction with CGI

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Javascript interaction with CGI
solspin
CZ Newbie
solspin has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Apr 20, 2005
0.00 posts per day
Posts: 2
Points: 65
   
My question is along the same lines as hundreds of others that I have read on message boards, but I am still trying to get a proper solution to the same old unanswered problem! The basic steps are (1) open popup window requesting <form> data (2) submit <form> using javascript (3) close popup (4) reload parent page. The solutions that I have seen have been along the lines of:

function submitForm()
{
document.forms[0].submit();
window.setTimeout('window.opener.location.reload()',120);
window.setTimeout('window.close()',120);
}

The problem with this coding is that (1) it assumes the <form> data from the popup will be sent within 120ms, and will close regardless. This causes inconsistent behavior in where the window will just close with no data submittal, or the data will be submitted in time and processed by the cgi script (proper function). (2) it assumes the cgi script will have processed the submitted data within that same 120ms time frame, and will refresh the parent page regardless. This again causes inconsistent behavior in where the parent page will refresh before the submitted data is processed, or the page will refresh after the data has been processed (proper function).

Is there anyway to syncronize the opening, closing, and refresing of windows with the cgi script?



Back to top Reply with quote
#2   re: Javascript interaction with CGI
solspin
CZ Newbie
solspin has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Apr 20, 2005
0.00 posts per day
Posts: 2
Points: 65
   
Just in case anyone else has this problem:

1. Don't use setTimeout(), it assumes too much about network and script response time.
2. To force the syncronization of the steps mentioned in the first post, return an empty
html page to the popup window with the following javascript in the header:


window.opener.location.reload();
window.close();


That's it!



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum