Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Trying To Poll Server Via Hidden IFrame

Reply
Thread Tools

Trying To Poll Server Via Hidden IFrame

 
 
pbd22
Guest
Posts: n/a
 
      03-14-2007
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

 
Reply With Quote
 
 
 
 
pbd22
Guest
Posts: n/a
 
      03-14-2007
On Mar 14, 10:12 am, Randy Webb <(E-Mail Removed)> wrote:
> 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



 
Reply With Quote
 
 
 
 
shimmyshack
Guest
Posts: n/a
 
      03-14-2007
On 14 Mar, 17:38, "pbd22" <(E-Mail Removed)> wrote:
> On Mar 14, 10:12 am, Randy Webb <(E-Mail Removed)> wrote:
>
>
>
> > 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?

 
Reply With Quote
 
pbd22
Guest
Posts: n/a
 
      03-15-2007
On Mar 14, 5:56 pm, Randy Webb <(E-Mail Removed)> wrote:
> pbd22 said the following on 3/14/2007 1:38 PM:
>
>
>
> > On Mar 14, 10:12 am, Randy Webb <(E-Mail Removed)> wrote:
> >> 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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select.poll.poll() never blocks birdsong Python 2 02-12-2009 07:14 AM
Re: select.poll.poll() never blocks Jean-Paul Calderone Python 3 02-12-2009 06:09 AM
print div only, via copying into hidden iframe first jon Javascript 10 12-06-2006 04:54 AM
Safari, hidden iframe, submit form target = iframe chris.alex.thomas@gmail.com Javascript 0 02-21-2006 01:48 AM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments