I know I can't serve a PDF file, and update a web page at the same time, so...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am building a site for a client of mine. He wants to be able to upload
files for his customers to download. Each customer can only view their
own documents, so these documents are placed in a directory specific to
the customer above the document root. The customer has to log in to
access the documents. He can go to a page where the documents in his
directory are listed. When he clicks on a document name, a script on the
server delivers the document.

Simple enough, except that the client wants two things. 1) At the top of
the page he wants a total count of the number of unread documents in the
customer's directory (Unread means the download link has not been
clicked). 2) He wants each document marked 'Read' or 'Unread.'

Fair enough, except that when a document is delivered, the count changes
and the marker for that document changes.

I can't deliver the document AND update the web page at the same time.
Can someone suggest an alternative that would give the customer the same
information and not be too complicated or cumbersome for the customer to

Re: I know I can't serve a PDF file, and update a web page at the sametime, so...

On Thu, 17 Jan 2013 09:20:47 -0700, Scott Bryce put finger to keyboard and

Quoted text here. Click to load it

This would be fairly trivial with Javascript. Have the link to download the
pdf trigger some code which updates the relevant section of the page.

A more robust solution would be to use an Ajax-like call to a script which
reads the current download totals from the database, and updates the page
accordingly. This, too, could be triggered by the download link, but it
could be done in such a way that it won't update the value if the file
isn't actually delivered.

Blog: http://mark.goodge.co.uk
Stuff: http://www.good-stuff.co.uk

Re: I know I can't serve a PDF file, and update a web page at the sametime, so...

On 1/17/2013 11:17 AM, Mark Goodge wrote:

Quoted text here. Click to load it

Wouldn't an AJAX-like solution update the page before the script
attempted to serve the file?

This may be the best option. I have very little AJAX experience, so I'm
fuzzy on how to approach this. And I don't want to update the page
unless the server-side script is certain that it was successful serving
the document.

Site Timeline