Skip to content

Instantly share code, notes, and snippets.

@danro
Created October 31, 2011 17:27
Show Gist options
  • Select an option

  • Save danro/1328077 to your computer and use it in GitHub Desktop.

Select an option

Save danro/1328077 to your computer and use it in GitHub Desktop.
Ajax preload w/ images
$.ajax({
...
success: function(data) {
var imageCount = $(data).filter('img').length;
var imagesLoaded = 0;
$(data).hide()
.appendTo('#someDiv')
.filter('img')
.load( function() {
++imagesLoaded;
if (imagesLoaded >= imageCount) {
$('#someDiv').children().show();
}
});
setTimeout( function() { $('#someDiv').children().show() }, 5000 );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment