I had the same problem that affected all firefox, chrome, etc. browsers, not only firefox, but only firefox showed the error message โImage is damaged or truncatedโ in the console log. the problem only occurs when the ajax request is too fast, which leads to a conflict between the beforeSend function and the success function. this is my code:
function loadlist(page, maxrows){ var orderby = $('.sortby_active').attr('title'); var category = $('.category_active').attr('title'); $.ajax({ type: 'post', url: 'gallery_pages.php?page=' + page + '&maxrows=' + maxrows + '&orderby=' + orderby + '&category=' + category, beforeSend: function(){ $('#page_loading').show(); $('#container').fadeOut(300); }, success: function(data){ $('#container').html(data); $('#container').stop().animate({'bottom': '0px'}, 100); n = 0; $('#up_arrow').hide(); $('#scrollup').css('cursor', 'default'); if(!$('#down_arrow').is(':visible')){ $('#down_arrow').show(); $('#scrolldown').css('cursor', 'pointer'); } $('#page_loading').hide(); $('#container').fadeIn(700); } }); }
A conflict in my code occurred between fadeIn and fadeOut. fadeout takes 300 ms, and if the ajax request is faster than 300 ms, it will show that ajax messages and response data will not be displayed properly. the solution was to use delay () in the success function. I delayed fadeIn by 310 ms just in case :)
function loadlist(page, maxrows){ var orderby = $('.sortby_active').attr('title'); var category = $('.category_active').attr('title'); $.ajax({ type: 'post', url: 'gallery_pages.php?page=' + page + '&maxrows=' + maxrows + '&orderby=' + orderby + '&category=' + category, beforeSend: function(){ $('#page_loading').show(); $('#container').fadeOut(300); }, success: function(data){ $('#container').html(data); $('#container').stop().animate({'bottom': '0px'}, 100); n = 0; $('#up_arrow').hide(); $('#scrollup').css('cursor', 'default'); if(!$('#down_arrow').is(':visible')){ $('#down_arrow').show(); $('#scrolldown').css('cursor', 'pointer'); } $('#page_loading').hide(); $('#container')**.delay(310)**.fadeIn(700); } }); }
source share