The only thing I can think of, if you want to trap the end of the download event for the zip is to somehow write a flag in your download.php when the file has finished sending to the client- I am not sure if this is possible in php, im pretty sure it isn't in ASP.
Your javascript can check the flag to see if the download has completed, and if it has, clear the flag... Since the file is streaming to the client, unless you can hook into an event (server side or otherwise) I dont think you have much choice. You must clear the database immediately after building the zip and sending it to the client, vs after the download has completed.. so why not just clear the display at the same time? Gareth On 3/20/07, Walter Lee Davis <[EMAIL PROTECTED]> wrote: > > > The cart loads at page load and then is continuously updated without > screen refresh. It is backed by the database, and that database is read > by download.php to get its list of files to download. If download is > successful in contacting the secure WEBDAV repository with all the big > files in it (the database is just a proxy), downloading the actual > files and mashing them into a zip -- then it clears the cart. > > But since I am just linking to (what appears to the browser as) a plain > zip file for download, and that zip file doesn't exist until the > download script has finished its business, I don't see how I can tell > the cart to update on screen after the download has finished. It's > tricky. > > Walter > > On Mar 19, 2007, at 5:14 PM, Gareth Evans wrote: > > > On your download link, apply an onclick handler as well as a href- the > > onclick can clear your on-screen shopping cart. > > When is the on-screen list being loaded? at page load, ie: the rest of > > the site isn't ajax based? Or does the cart remain onscreen at all > > times with no refresh. > > > > <a href="downloadlink.php" onclick="clearCart();return true;"> > > (inline handlers are bad) > > This will cause the cart to clear, then the user will navigate to > > downloadlink.php. > > If you didn't want them to download, you could return false. > > If you attach the event with Event.Observe you have to use > > Event.Stop(e) though > > > > Hope this helps > > > > Gareth > > > > On 3/20/07, Walter Lee Davis <[EMAIL PROTECTED]> wrote: > >> I have a shopping cart on a page that gathers files for download. As > >> the user browses around the various nested folders, she can add things > >> to the cart, remove single items from the cart, and empty the entire > >> cart. At any time, she can also download the entire cart contents as a > >> Zip archive. > >> > >> I am managing that download using a PHP script that forces the > >> file-type, and thus all I do is link to a real file > >> (download.php?cart=N) from my page. The last step of the download > >> script is to empty out the cart in the database. But the list on > >> screen > >> remains the same until the visitor navigates to another folder, at > >> which point it refreshes and declares itself empty. Which is kind of > >> jarring to the user. > >> > >> I tried applying a periodic updater to the cart div, and that did > >> work, > >> but it also killed the other events I had registered inside that div > >> (the individual files' remove me buttons). It also issued a request > >> every five seconds, which seems extreme. > >> > >> I am experimenting with just setting a delay after the click and > >> checking the cart again, but that seems fragile, since I don't know > >> how > >> long it might take for the server to respond with the files. If I > >> check > >> before it's done, the cart will be the same (since the download hasn't > >> started yet and the script returned true) and if I wait too long, it > >> will be jarring for the user. > >> > >> Any suggestions? I can't show any code, it's all hidden inside an > >> HTTPS > >> site. I could do some extractions, I guess, but I am hoping someone > >> may > >> have done this before and have a bright idea or two. > >> > >> Thanks, > >> > >> Walter > >> > >> > >> > >> > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
