views:

96

answers:

2

I have a multiple language site. With html, javascript, may be ajax if an image does not exist in spanish folder, it should load image from the english folder.

path example english site : images/home.jpg spanish site : es/images/home.jpg

Today i have message.properties ... stuff for doing text conversion message.properties message_es.properties

+3  A: 

You can use onerror for the image

<img src="es/images/home.jpg" onerror="this.src='images/home.jpg'">

but, IMHO, it is better to do the job on server side

Rafael
Clever. A pain if it's site-wide though.
Diodeus
A: 

I'd agree with Rafael that it's better to handle that sort of thing on the server side, but if you have to do it via AJAX and handle it with javascript, I'd just check to see if your AJAX call returned with a 404 code after requesting the image, if so, proceed to load the English version.

Damoon Rashidi