I need to poll the image using javascript and you need to perform an action as soon as the image is found in its position. This is the code I wrote for this task.
var beacon = new Image(); beacon.onload = function() { console.log('Image found'); console.log(this.width,this.height); window.clearInterval(timer); }; beacon.onerror = function(){ console.log('Image not found'); } var timer = window.setInterval(function(){ console.log('sending the request again'); beacon.src = "http://www.google.co.in/logos/2010/lennon10-hp.gif"; },2000);
The problem is that after one GET request, the response becomes cached and the request is not sent every time I install src. If you are viewing the NET tab, it only sends a request to the first src set and caches the response.
I need to send a new request for an image every time my code sets src. Any workarounds?
source share