jQuery equivalent of PHP's file_exists()?
Posted
by Scott B
on Stack Overflow
See other posts from Stack Overflow
or by Scott B
Published on 2010-03-22T05:52:06Z
Indexed on
2010/03/22
6:01 UTC
Read the original article
Hit count: 177
jQuery
In the code snippet below, from my jQuery setup, I need to check if the image file actually exists and if not, I'd like to substitute a default image. Currently if the file does not exist, I just get a broken image placeholder...
$('#myTheme').change
(
function()
{
var myImage = $('#myTheme :selected').text();
$('.selectedImage img').attr('src','../wp-content/themes/myTheme/styles/'+myImage+'/screenshot.jpg');
//if screenshot.jpg does not exist, use "../../default.jpg" instead
}
);
© Stack Overflow or respective owner