On my site, I display an image after the user clicks on a thumbnail (opens in a lightbox). I want to store the number of times users open the images.
I was thi开发者_JAVA技巧nking of something like pointing to an ASHX page that generates the image and updates the DB with the view count, but this can't be done since this is a remote file from a CDN. I can't just count the thumbnail clicks, since the image opens in lightbox.
Can anybody suggest a way I can accomplish what I'm trying?
Thanks, WT
Because you're using javascript to open the image in the lightbox just add some code to make an ajax call at that point to your ashx handler. The handler should just record that the image has been viewed.
You could also add a javascript call to the thumbnail click and have that call back to the server to increment the count.
精彩评论