Trying To Poll Server Via Hidden IFrame

P

pbd22

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
 
P

pbd22

pbd22 said the following on 3/14/2007 12:48 PM:



What "online errata"?



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/webcontent/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
 
S

shimmyshack

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/webcontent/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=uploadedfilename"
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?
 
P

pbd22

pbd22 said the following on 3/14/2007 1:38 PM:








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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top