trican — 2011-04-13T07:37:50-04:00 — #1
So my questions are: will this be relatively straightforward? And secondly do you know of any links that might be useful for me in getting started with this?
trican — 2011-04-13T16:28:15-04:00 — #2
I guess my question is probably a little too vague - I'll do a spot more investigation myself and then I'll come back with more focused questions
samanime — 2011-04-13T16:52:09-04:00 — #3
If you change the src of an image, it'll cause that image to load.
If you want to load the same image again, you can append something random to the end, after a question mark.
Ex., I have an image called "image.png". I want to force it to reload, so I just add something random to the end, like a random number, so it becomes:
"image.png?1542". The same file will load, but the browser thinks it's different, so it causes it to load again.
Hope that helps.
klucid — 2011-04-14T18:03:51-04:00 — #4
Thank you for the tip... I wanted to have an image refresh whenever a user came to the page. It helped me come up with the idea to use PHP to generate a random number, thus forcing the browser to refresh.
<img src="this-week.png?<?php echo rand(5, 9); ?>" />
trican — 2011-04-15T19:49:12-04:00 — #5
Thanks so much for the info! I now have the image reload working fine, never thought it would be so straight forward. The next thing I need to do is to call a php file via ajax. Is it straight forward to get the image reload to wait until the ajax call has finished?
Many thanks again!
felgall — 2011-04-15T20:21:17-04:00 — #6
trican — 2011-04-16T08:46:18-04:00 — #7
thanks - that makes sense
trican — 2011-04-17T04:42:29-04:00 — #8
For the most part the image reload is working perfectly - though for larger images, there is a noticeable delay between clicking the link/button and the image reloading - would it possible to show a twirling animation before the file is actually ready for reload?
samanime — 2011-04-18T12:31:26-04:00 — #9
Yeah, you'd want to use a preloader.
trican — 2011-04-18T17:19:05-04:00 — #10
Great suggestion - I'm off to implement this. I think I still need to figure out how to display a spinning gif when loading content. Maybe for another day and a separate thread. thanks everyone for the help!
samanime — 2011-04-18T17:26:20-04:00 — #11
Basically all you do is hook in an event for when the image is done loading.
Then, when you go to change it, change it to the spinning gif.
Then, once it's done loading, change the spinning gif to the image you just loaded.