Date:  09/03/2017 03:27:01 AM Msg ID:  004898
From:  Art Bergquist Thread:  004894
Subject:  Re: Poll until file exists on server
Now that I'm able to retrieve the name of the generated .PDF file, I'm trying to implement JavaScript in the window.onload event to do the following:
  1. display a 'Generating .PDF file ...' message
  2. call a function to see if the file exists
  3. if the file doesn't exist, wait for a second and go back to Step 2
  4. if the file exists, then stop the above loop (Steps 2-3) and hide the 'Generating .PDF file ...' message

I've tried a timer, promise, web worker, etc. but, as of yet, no joy.
Anyone have ideas how they would tackle this (or how they have tacked a similar scenario)?
Sent by Art Bergquist on 09/02/2017 11:12:32 PM:
Switching to a cookie did the trick; I can set the cookie via FoxWeb:
  Response.SetCookie("generatedPdfFileName", m.lcWebFile)
and then parse it out of document.cookie via JavaScript in the window.onload() event function.
Sent by Art Bergquist on 09/02/2017 10:50:08 PM:
I then implemented a hidden field whose value is the name of the .PDF file but when I query that field with either of the following lines:
I get null back both times. 
Sent by Art Bergquist on 09/02/2017 09:25:06 PM:
I've got a web page in which I programmatically create an .html file in a certain folder/directory on the server.

My client has ActivePDF's DocConverter running on the server; DocConverter watches that folder/directory so that anytime an .html file gets created there, DocConverter automatically generates a .PDF file from the .html file.
The issue is that when the web page displays with a hyperlink to the .PDF file, the .PDF file has not always been generated yet (in fact, most of the time, the .PDF is not immediately available).
I'm looking to implement JavaScript in the window.onload event to poll the server to see when the file exists.  I've got a function to see if a file exists.  What I'm currently researching is how to pass the name of the .PDF file from the VFP code in the .FWx to the JavaScript in the window.onload event (in the same .FWx).
I implemented the following line immediately after initializing the memory variable for the name of the generated .PDF file:
  Session.SetVar('generatedPdfFileName', m.lcWebFile)
but when the following code gets called from the window.onload event:
it throws an "Uncaught ReferenceError: session is not defined" error.
Any thoughts? 
Art Bergquist