Why store the cart on the server? why not locally? Maybe some sort of iframe hack would let you download the file and attach an event on completion but I'd think that clearing the cart when they click the download link would be good enough. Only disadvantage would be if they clicked cancel they'd have to refill the cart to try again, but you can only account for so much carelessness on behalf of the user :)  See http://ecosmear.com/relay/

Colin

Walter Lee Davis 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="" >
(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
-~----------~----~----~----~------~----~------~--~---

Reply via email to