Laden Sie Bilder von einem Ajax-Aufruf vor
Könnte mir jemand helfen, zu verstehen, wie man die Bilder von der random.php-Seite vorlädt, damit sie beim ersten Laden wie gewünscht eingeblendet werden. Momentan hat es ein hässliches Bulk-Echo, weil sie nicht vorinstalliert sind, aber sobald die Seite ausgeführt wurde, wird sie perfekt nacheinander eingeblendet ...
//Loop through the images and print them to the page
for (var i=0; i < totalBoxes; i++){
$.ajax({
url: "random.php?no=",
cache: false,
success: function(html) {
// following line I originally suggested, but let's make it better...
//$('#bg').append(html).fadeIn('slow');
// also note the fine difference between append and appendTo.
var $d = $(html).hide().appendTo('#bg').fadeIn('slow');
$('img', $d).hover(function() {
var largePath = $(this).attr("rel");
$(this).fadeOut("slow", function() {
$(this).attr({ src: largePath }).fadeIn("slow");
});
});
}
});
}