如何在Bootstrap轮播中添加最新图像?

时间:2018-01-04 10:26:58

标签: jquery html ajax twitter-bootstrap carousel

我开发了一个Web应用程序。其中主要由Carousel和Table组成。 Carousel将以更大的尺寸显示图像,而表格显示图像缩略图,到目前为止我一直在做的是我在document.ready()上发出了ajax请求,我可以更新轮播和表格。但是现在,我需要更新Web应用程序以定期发出ajax请求。

我的问题是如何在不清除所有项目的情况下将最新图像添加到现有的轮播中,因为我需要先显示最新图像。

任何建议或解决方案都将受到赞赏。

我的代码在ajax请求中附加轮播项:

for (var i = 0; i < jsonobj.length; i++) {

    $(".carousel-indicators").append('<li data-target="#myCarousel" data-slide-to="' + i + '" > </li>');

    $(".carousel-inner").append('<div class="item"> <img src="' + jsonobj[i].img_path + '" alt="Image"> <div class="carousel-caption"> <h3>' + jsonobj[i].img_name + '</h3> </div> </div>');
}

0 个答案:

没有答案