I am refreshing images from webcams every second on an app. The problem I have is if for a few seconds an image is not retrieved from the camera (which happens frequently) I end up with a broken image. I would like to have it so that it only refreshes if and when a new image is found. 

So far I have

```
var int_time = setInterval(function() {
   var myImageElement = document.getElementById('myImage');
   myImageElement.src = '<%= EVERCAM_API %>cameras/<%= @camera["id"] %>/snapshot.jpg?api_id=<%=  current_user.api_id %>&api_key=<%= current_user.api_key %>&rand=' + new Date().getTime();
}, 1000);

```

Is it possible to stop the refresh if the image not retrieved?