我碰到从这里Twitter的引导旋转木马。 http://twitter.github.com/bootstrap/javascript.html#carousel
I came across a carousel from Twitter bootstrap here. http://twitter.github.com/bootstrap/javascript.html#carousel
这看起来非常好。但是,所有的图像/在这个例子中内容是硬codeD。我该如何向服务器请求新的内容,并显示在旋转木马?
It looks really good. But all the images / content in the example are hard-coded. How can I request the server for new content and show it in the carousel?
答案将会对每种语言进行调整,但假设你的编程在PHP中,它可能看起来是这样的:
The answer would have to be adjusted for each language, but assuming you're programing in PHP, it may look something like this:
如果您有图像的数组:
$images = ['path/to/image.jpg', 'path/to/image2.jpg', 'path/to/image3.jpg']
,那么你会通过这些图像环路,并把每一个在相应的HTML标记,像这样:
Then you'd loop through those images, and place each one in the appropriate HTML markup, like so:
<?php foreach ($images as $image) { ?>
<div class="item">
<img src="<?php echo $image ?>" />
</div>
<?php } ?>