我在互联网上搜索了很多内容,但对我来说没什么用。这是相关的代码。我试图关注此链接Owl carousel with ajax demo,但可能是我错过的内容。
HTML
<div id="footer-gallery" class="owl-carousel owl-theme">
</div>
JS
$.ajax({
url: siteUrl,
type: 'POST',
data: {
page_no: pageNumber,
},
success: function(data) {
if(data.status == 200)
owl.trigger('insertContent.owl',[data.html]);
},
error: function(e) {
}
来自ajax的HTML数据
<div class="item"> image content here </div>
<div class="item"> image content here </div>
在ajax调用之后,初始html会像这样改变。
更改了HTML
<div class="owl-carousel owl-theme owl-loaded" id="footer-gallery">
<div class="owl-stage-outer">
<div class="owl-stage"></div>
</div>
</div>