Show AJAX content after images have loaded

Posted by Ben4Himv on Stack Overflow See other posts from Stack Overflow or by Ben4Himv
Published on 2010-06-08T14:29:56Z Indexed on 2010/06/08 14:42 UTC
Read the original article Hit count: 149

Filed under:
|
|
|
|

I am developing my own lightbox kind of jquery plugin. Everything works but I want to hide the loaded content until the images have loaded in the browser from the AJAX call. I found a similar post and I am using the following script but the setTimeout function is what reveals the content and not the .load function. Am I trying to achieve the impossible?

$.ajax({
      url: 'meet/'+ pLoad + '.html',  
      success: function(data) {
        var imageCount = $(data).filter('img').length;
        var imagesLoaded = 0;
        $(data).hide()
         .appendTo('#zoom_inner')
         .filter('img')
         .load( function() {
          ++imagesLoaded;
          if (imagesLoaded >= imageCount) {
          $('#zoom_inner').children().show();
          }
          });
        setTimeout( function() { $('#zoom_inner').children().show() }, 5000 );
       }
    });

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery