By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,205 Members | 938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,205 IT Pros & Developers. It's quick & easy.

Trying To Poll Server Via Hidden IFrame

P: n/a
Hi.

I am trying to poll a long-running process via a hidden IFrame.
I am noticing that the online errata gives advice for handling a
server response:

window.parent.handleServerResponse();

The problem I am having with this is that the above function
gets called ***after*** the long-running response is completed.
How do I poll the long-running process ****as**** it is being
executed? Say, every 5 seconds or so?

I thank you for your help.
Peter

Mar 14 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
pbd22 said the following on 3/14/2007 12:48 PM:
Hi.

I am trying to poll a long-running process via a hidden IFrame.
I am noticing that the online errata gives advice for handling a
server response:
What "online errata"?
window.parent.handleServerResponse();

The problem I am having with this is that the above function
gets called ***after*** the long-running response is completed.
How do I poll the long-running process ****as**** it is being
executed? Say, every 5 seconds or so?
You have the long-running process update a file on the server. Then you
check the file for the status. It could be as trivial as setting a
variable to false and when it finishes changes that variable to true.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 14 '07 #2

P: n/a
On Mar 14, 10:12 am, Randy Webb <HikksNotAtH...@aol.comwrote:
pbd22 said the following on 3/14/2007 12:48 PM:
Hi.
I am trying to poll a long-running process via a hidden IFrame.
I am noticing that the online errata gives advice for handling a
server response:

What "online errata"?
window.parent.handleServerResponse();
The problem I am having with this is that the above function
gets called ***after*** the long-running response is completed.
How do I poll the long-running process ****as**** it is being
executed? Say, every 5 seconds or so?

You have the long-running process update a file on the server. Then you
check the file for the status. It could be as trivial as setting a
variable to false and when it finishes changes that variable to true.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Hi Randy,

Thanks for your reply.
Well, that particular function comes from the below link:

http://www.bazon.net/mishoo/rpc.epl

But, the "online errata" that I have been following most closely has
been the bit about RPCs by the engineers at Apple:

http://developer.apple.com/internet/...nt/iframe.html

In both cases, I have found that when my long-running process
(in this case a video upload via hidden iframe) has completed,
the client-side function gets called.

I want to poll the long-running process **as it is happening**. The
polling routine will query information provided by the server page
(bytes uploaded, percent, total bytes, time, etc) and return that
information to the client in intervals of a few seconds for an in-
process client-side progress display.

I am glad to hear this isn't too complicated. I am wondering if you
wouldn't mind providing the steps, code, links, or whatever you think
could help me get my mind wrapped around what I am trying to do. I'd
apprecaite that.

Thanks again.
Peter

Mar 14 '07 #3

P: n/a
On 14 Mar, 17:38, "pbd22" <dush...@gmail.comwrote:
On Mar 14, 10:12 am, Randy Webb <HikksNotAtH...@aol.comwrote:
pbd22 said the following on 3/14/2007 12:48 PM:
Hi.
I am trying to poll a long-running process via a hidden IFrame.
I am noticing that the online errata gives advice for handling a
server response:
What "online errata"?
window.parent.handleServerResponse();
The problem I am having with this is that the above function
gets called ***after*** the long-running response is completed.
How do I poll the long-running process ****as**** it is being
executed? Say, every 5 seconds or so?
You have the long-running process update a file on the server. Then you
check the file for the status. It could be as trivial as setting a
variable to false and when it finishes changes that variable to true.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Hi Randy,

Thanks for your reply.
Well, that particular function comes from the below link:

http://www.bazon.net/mishoo/rpc.epl

But, the "online errata" that I have been following most closely has
been the bit about RPCs by the engineers at Apple:

http://developer.apple.com/internet/...nt/iframe.html

In both cases, I have found that when my long-running process
(in this case a video upload via hidden iframe) has completed,
the client-side function gets called.

I want to poll the long-running process **as it is happening**. The
polling routine will query information provided by the server page
(bytes uploaded, percent, total bytes, time, etc) and return that
information to the client in intervals of a few seconds for an in-
process client-side progress display.

I am glad to hear this isn't too complicated. I am wondering if you
wouldn't mind providing the steps, code, links, or whatever you think
could help me get my mind wrapped around what I am trying to do. I'd
apprecaite that.

Thanks again.
Peter
why not have a second iframe, hidden like the first (OR use XHR), but
this one is used to receive data.
you /can/use the other one provided it is able to keep flushing small
bits of javascript back. In the past I have found the simpler way was
to keep querying a 2nd iframe (or scriptin using XHR) whose source is
"are_we_there_yet_papa_smurf.php?filename=uploaded filename"
or where a session is set and the filename is not needed to be sent.

that way the are_we_there_yet_pap_smurf.php script can stat the
uploading file, perform the calculations and send back the data inside
script tags, (or when using XHR, pre JSON data for security)
a receiving script in the parent then uses this javascript data to
update the DOM with the details.
you call are_we_there_yet_pap_smurf.php using an interval (or
setTimout) based on a variable sent back, doagain = 1, on upload
succeeded the variable is changed to doagain = 0; and the thing
updates once with the final data, and stops.

Does that all make sense?

Mar 14 '07 #4

P: n/a
pbd22 said the following on 3/14/2007 1:38 PM:
On Mar 14, 10:12 am, Randy Webb <HikksNotAtH...@aol.comwrote:
>pbd22 said the following on 3/14/2007 12:48 PM:
>>Hi.
I am trying to poll a long-running process via a hidden IFrame.
I am noticing that the online errata gives advice for handling a
server response:
What "online errata"?
>>window.parent.handleServerResponse();
The problem I am having with this is that the above function
gets called ***after*** the long-running response is completed.
How do I poll the long-running process ****as**** it is being
executed? Say, every 5 seconds or so?
You have the long-running process update a file on the server. Then you
check the file for the status. It could be as trivial as setting a
variable to false and when it finishes changes that variable to true.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Hi Randy,

Thanks for your reply.
Well, that particular function comes from the below link:

http://www.bazon.net/mishoo/rpc.epl

But, the "online errata" that I have been following most closely has
been the bit about RPCs by the engineers at Apple:

http://developer.apple.com/internet/...nt/iframe.html

In both cases, I have found that when my long-running process
(in this case a video upload via hidden iframe) has completed,
the client-side function gets called.

I want to poll the long-running process **as it is happening**. The
polling routine will query information provided by the server page
(bytes uploaded, percent, total bytes, time, etc) and return that
information to the client in intervals of a few seconds for an in-
process client-side progress display.

I am glad to hear this isn't too complicated. I am wondering if you
wouldn't mind providing the steps, code, links, or whatever you think
could help me get my mind wrapped around what I am trying to do. I'd
apprecaite that.
The IFrame that is hosting the call to the "long running process" can
also poll the server to see if the long running process is finished or
not. One possible way of doing that is to modify the long running
process to write a file - on the server - that estimates how far along
it is. Your second poll checks that file and sees where it is at. Then
it can update the main page.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 15 '07 #5

P: n/a
On Mar 14, 5:56 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
pbd22 said the following on 3/14/2007 1:38 PM:
On Mar 14, 10:12 am, Randy Webb <HikksNotAtH...@aol.comwrote:
pbd22 said the following on 3/14/2007 12:48 PM:
>Hi.
I am trying to poll a long-running process via a hidden IFrame.
I am noticing that the online errata gives advice for handling a
server response:
What "online errata"?
>window.parent.handleServerResponse();
The problem I am having with this is that the above function
gets called ***after*** the long-running response is completed.
How do I poll the long-running process ****as**** it is being
executed? Say, every 5 seconds or so?
You have the long-running process update a file on the server. Then you
check the file for the status. It could be as trivial as setting a
variable to false and when it finishes changes that variable to true.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Hi Randy,
Thanks for your reply.
Well, that particular function comes from the below link:
http://www.bazon.net/mishoo/rpc.epl
But, the "online errata" that I have been following most closely has
been the bit about RPCs by the engineers at Apple:
http://developer.apple.com/internet/...nt/iframe.html
In both cases, I have found that when my long-running process
(in this case a video upload via hidden iframe) has completed,
the client-side function gets called.
I want to poll the long-running process **as it is happening**. The
polling routine will query information provided by the server page
(bytes uploaded, percent, total bytes, time, etc) and return that
information to the client in intervals of a few seconds for an in-
process client-side progress display.
I am glad to hear this isn't too complicated. I am wondering if you
wouldn't mind providing the steps, code, links, or whatever you think
could help me get my mind wrapped around what I am trying to do. I'd
apprecaite that.

The IFrame that is hosting the call to the "long running process" can
also poll the server to see if the long running process is finished or
not. One possible way of doing that is to modify the long running
process to write a file - on the server - that estimates how far along
it is. Your second poll checks that file and sees where it is at. Then
it can update the main page.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Thanks Both.
This has been an extremely helpful thread.
Randy, I like your idea of using the same iframe for polling as
upload, but only have one question about writing to a second file for
data updates. I have designed a custom event handler that gets called
every time bytes get uploaded to the FTP server. This event handler
would be updating the second page with new upload information. To me,
this means that there would be a ton of read/writes happening on the
server as the data page gets updated. Wouldn't this method be sort of
costly to the server?

Mar 15 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.