0
I inserted after loading all the content of my website the function below, and is returning an error message on the console.
Typeerror: $(...). error is not a Function
I tried to fix it using the jQuery.noConflict() but the error persists.
I’m using jQuery version 3.3.1.
$(document).ready(function(){
$(function() {
var $images = $('img.imageClassUpdateAtInterval:not([src="/assets/images/ico-loading.gif"])');
// Now, no such image with
// a spinner
if($images.length === 0 && window.imageLocator)
clearInterval(window.imageLocator);
window.imageLocator = setInterval(function() {
$images.each(function() {
$this = $(this);
if (!$this.data('src')) {
$this.data('src', $this.prop('src'));
}
$this.prop('src', $this.data('src') + '?timestamp=' + new Date().getTime());
console.log($this.prop('src'));
});
}, 60 * 8000);
// suppose, an error occured during
// locating the src (source) of the
// image - image not found, network
// unable to locate the resource etc.
// it will fall in each time on error
// occurred
$('img.imageClassUpdateAtInterval').error(function () {
// set a broken image
$(this).unbind("error").attr("src", "/assets/images/ico-loading.gif");
// setting this up in relative
// position
$(this).css("position", "relative");
$(this).apppend("<span><!--error--></span>");
$(this).find("span").css({"position": "absolute", "background-color": "#252525", "padding": ".3em", "bottom": "0"});
});
});
})
Have you checked whether the reference for jquery is loaded before running this script?
– Sérgio Lopes
@Sérgiolopes is yes, the function runs after the file load.
– ElvisP