所以我从 php 中获取数组,如下所示:
<?php
$images = glob('../images/intro/*.{png,jpg,jpeg}',GLOB_BRACE);
//Encode Javascript Object Notation
echo json_encode($images);
?>
然后使用 jquery 我得到数组并对其进行解码:
$.ajax({
url: 'ajax/intro.php',
success: function(data){
//Decode the received array
data = JSON.parse(data);
//read each image path from the array
$.each(data, function(index, value) {
setTimeout(function() {
$('.container').fadeIn(500, function() {
$(this).delay(500).fadeIn(500, function(){
alert(value);
//Want to display each image inside the div with class container!
//The tag img doens't exist I belive I should do something like:
$('.conatiner').append('<img src=\"'+value+'\" />');
});
})
}, index * 1500);
});
}
});
这是可行的,但我想在警报消息之后立即显示图像(警报消息仅用于测试目的),我该如何实现?
此外,在显示图像后想要淡出......我很感激这里的一些帮助。谢谢你,联邦通信委员会。