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
}
);
It sounds like you need access to the HTTP response headers. Here’s a piece of code I found on the Internet.
Source: http://www.vfstech.com/?cat=1