我收到以下錯誤:TypeError:幻燈片[i]未定義。TypeError:variable is undefined
它的奇怪,因爲它不應該能夠訪問幻燈片變量?
<script>
$('document').ready(function() {
$.ajax({
type: "POST",
url: "getSlides.php",
data: '',
cache: false,
success: function(response)
{
var slides = JSON.parse(response);
for (var i = 0; i < slides.length; i++) {
setTimeout(function() {
if (slides[i].type === 'image') {
$('#slideshow').html('<img src="' + slides[i].image_video + '" />');
}
}, 2000);
}
}
});
});
</script>
你肯定'slides'變量是一個數組? – VisioN