I have a script that causes if the iframe could not be loaded show a reporting div of the error:
var iframe = $( '#meuIframe' );
var url = 'http://link.com/iframe.html';
$.get( url, function ( data ) {
iframe.onload = function () {};
iframe.src = url;
}).error( function ( err ) {
$('.errorDiv').show();
});
So far so good, but I wanted to be able to update this iframe for a button. I got it like this:
$("#refresh").attr("src", "http://link.com/iframe.html?"+new Date().getTime());
}
... But the error div does not appear if there is an error, as in the first script. So I tried to do this:
$("#refresh").click(function(){
var iframe = $( '#meuIframe' );
var url = 'http://link.com/iframe.html';
$.get( url, function ( data ) {
iframe.onload = function () {};
iframe.attr("src", = url? +new Date().getTime());
}).error( function ( err ) {
$('.errorDiv').show();
});
});
But it does not work. Can you help me?