0
I need to verify the existence of an image coming in one of the positions of a JSON received via AJAX. Did you understand?
Is there any function equivalent to file_exists() PHP in Javascript or jQuery?
$.ajax({
url:'http://www.example.com/verificafotos.json',
success: function(dados) {
$.each(dados, function(index,value){
value['titulo'];
value['imagem'];
if( SE O ARQUIVO EXISTIR (value['imagem'])) {
$('img').src(value['imagem']);
} else {
$('img').src('http://www.example.com/imagemalternativa.jpg');
}
});
}
});
You want to know if some value has something with the image extension, like . png, . jpg etc, or a <img tag>?
– Sam
I import the data from a DB with the image information (fototeste.jpg) and the folder where the photos are. But the image does not always exist in the folder. When mounting the structure, coming from a JSON, does not display the image on the system.
– Márcio Teixeira