/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] using ajax to know when an image is loaded

Hi there,

Well – I have just started using ajax, it’s really sweet – I mean, you can do tons of cool stuff just with response.Text… This is what I was wondering though.

Can I use AJAX to tell when an image is loaded? Like – say I have some thumbnails and a div tag that has a larger image – I can easily replace the larger divs background image with whatever I want using javascript, no AJAX needed – however I want to find out if I can figure out when the image is loaded so that first I can display a “loading image” in the div then I can show the actual image after it is transfered from the server.

Thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Typhoon101Feb 22.2008 — Why use AJAX? The <IMG> tag has an attribute called lowsrc. This points to a low resolution file which is used until the high res image has downloaded.

e.g.

<img src="high-res-image.jpg" lowsrc="loading-image.gif" />
Copy linkTweet thisAlerts:
@r0k3tauthorFeb 22.2008 — Wow - how about I never even new that existed... Thanks for the tip.
×

Success!

Help @r0k3t spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...