[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Detect when form submission is complete

Posted on 2004-11-03
12
Medium Priority
?
316 Views
Last Modified: 2008-03-10
I have a form which submits to a page on a server that takes a few minutes to load and process the data. During which time, most browsers display the progress bar at the bottom. When the server is done processing the info, it returns a "204 No Content" and the browser stops. I need to detect when this has happened, so I can redirect to another page. I can't change the way the server responds, so this will have to be implemented client-side, presumably using Javascript. Thanks in advance!
0
Comment
Question by:J-Mik
  • 5
  • 4
10 Comments
 
LVL 25

Accepted Solution

by:
devic earned 252 total points
ID: 12483716
here ix an example, the iframe can be hidden:
=============================
<script>
function notification()
{
      var theHREF;
      try
      {
            theHREF=frames.hdIframe.location.href;
      }
      catch(e)
      {
            theHREF="access denied"
      }
      if(theHREF!="about:blank")
      {
            alert("form submited!")
      }
}
</script>

<form action=http://www.google.com/search target="hdIframe">
      <input name=q value=hurra>
      <input type=submit>
</form>
<iframe name=hdIframe src=about:blank onload="notification()"></iframe>

0
 
LVL 1

Author Comment

by:J-Mik
ID: 12483979
Devic,

This doesn't seem to work. The onLoad event of the IFRAME triggers as soon as the page with the form loads (before the submitting happens) and then does not trigger again even after the form is submitted through it.
0
 
LVL 25

Expert Comment

by:devic
ID: 12484034
that happens, because you changed my code or you are using only a part of this.
show me what you do, and I tell you what is wrong
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Assisted Solution

by:GwynforWeb
GwynforWeb earned 248 total points
ID: 12484221
try this

<script>
function notification()
{alert("form submission finished!")
}
flag=false
</script>

<form action="http://www.google.com/search" target="hdIframe">
 <input name="q" value="hurra">
 <input type="submit">
</form>

<IFRAME name="hdIframe" src="about:blank" onload="(flag)?notification():flag=!flag">
</IFRAME>
0
 
LVL 1

Author Comment

by:J-Mik
ID: 12484225
Well, I don't think I changed anything, but here's the code anyways:

 <SCRIPT TYPE="text/javascript">
 <!--
                                       
   function Check() {
     var HREF;
     try {
       HREF = frames.HFrame.location.href;
     } catch(Err) {
       HREF = "Access Denied";
     }
     if (HREF != 'about:blank') { alert(HREF); }
   }
                                       
 //-->
</SCRIPT>

<FORM ACTION="default.asp" METHOD="Post" TARGET="HFrame">
<TABLE CELLPADDING=0 CELLSPACING=10 BORDER=0 ALIGN="Center">
   <TR VALIGN="Middle">
     <TD><INPUT TYPE="Text" SIZE=20 MAXLENGTH=20 ID="Username" NAME="Username"></TD>
     <TD ROWSPAN=2 ALIGN="Center"><INPUT TYPE="Image" SRC="/Button-Submit.gif"></TD>
  </TR>
   <TR>
     <TD><INPUT TYPE="Password" SIZE=20 MAXLENGTH=20 ID="UserPass" NAME="UserPass"></TD>
  </TR>
</TABLE>                                            

</FORM>
<IFRAME NAME="HFrame" ID="HFrame" SRC="about:blank" onLoad="Check()"></IFRAME>


I tested this in Internet Explorer, Firefox and Opera, and in all three cases, the function is not run when the form is done submitting. Don't forget that the server does not return a blank page, it return a 204, which means the IFRAME's location never changes. Thanks again.
0
 
LVL 25

Expert Comment

by:devic
ID: 12484426
can you give the full url of the action?
0
 
LVL 1

Author Comment

by:J-Mik
ID: 12484537
Devic,
"default.asp" is the full URL. It's an IIS page hosted on the same machine that this page runs on, in the local Intranet.

GwynforWeb,
Thanks for the try, but your code doesn't change anything. The function still isn't called a second time (again, probably because the page is not loaded)
0
 
LVL 25

Expert Comment

by:devic
ID: 12484606
the same machine....
why you don't use  Response.Redirect ?
0
 
LVL 1

Author Comment

by:J-Mik
ID: 12484807
Devic,

As I mentionned, I cannot change the server's script at all, so this is not an option. :)
0
 
LVL 25

Expert Comment

by:devic
ID: 12485236
J-Mik,

then I would say you can not do nothing...

or probably you must ask the people, who can change this file ;)

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

867 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