I think this is the easiest tool you can use.

jQuery.Preload: http://flesler.blogspot.com/2008/01/jquerypreload.html

It has all you need.
You send the img tag to the preloader and using the options 'find' and
'replace' you generate the replacement url.
Using the option 'placeholder' you to set a loading image or any type
of placeholder while it preloads.
By using the onComplete callback, you can detect whether it failed,
and act accordingly.

Instead of find and replace, you can preload the src (as a string)
directly.
In the onComplete callback, you set the new url to the img.

Cheers
--
Ariel Flesler
http://flesler.blogspot.com

On 27 mayo, 17:49, "Andy Matthews" <[EMAIL PROTECTED]> wrote:
> I have a default image loaded into an img tag with an id of "specialImage".
> I also have a select box which displays a list of vehicles. The value of
> each option is a filename (75682.jpg, 75123.jpg, etc.).
>
> When the user selects a vehicle, I want to change the src of the img tag but
> I'm running into a few issues that I'm not sure how to get around.
>
> 1) Because I'm not using an AJAX call, I don't know if the file actually
> exists on the server. A few images are then showing as broken which is a big
> no no.
>
> 2) The images being loaded in aren't huge, but they might be 40k or so.
> Because I'm simply changing the src, I can't display a loading image while
> the requested image is loading.
>
> Are there ways around this? I'm thinking I could do an AJAX call to get the
> response headers for the file. When I trigger the AJAX call, I'd display the
> loading image. Then, if the response comes back 200, then I can display the
> actual file, if not, I can display a "no image available" image.
>
> Any thoughts on this method? Is there a better way to do this?
>
> ____________________________________
>
> Andy Matthews
> Senior ColdFusion Developer
>
> Office:  615.627.9747
> Fax:  615.467.6249www.dealerskins.com<http://www.dealerskins.com/>
>
> Total customer satisfaction is my number 1 priority! If you are not
> completely satisfied with the service I have provided, please let me know
> right away so I can correct the problem, or notify my manager Aaron West at
> [EMAIL PROTECTED]
>
>  2008 Email NADA.jpg
> 17 KVerDescargar

Reply via email to