我有一个以上的ajax页面,我想要在滚动后加载我的ajax页面,我该怎么做?我有一个简单的基本结构,我想加载我的ajax滚动后像无限滚动或懒惰的图像。如何在滚动后加载ajax?
$('.lazy_content').on('load', function (e) {
data_url = $(this).attr("data-url");
data_id = $(this).attr("data-target-id");
$.ajax({
url: data_url,
type: "POST",
beforeSend: function() {
$(".loaderDiv").show();
$("#" + data_id).html("");
},
success: function (data) {
$(data).each(function(index, el) {
\t $(".loaderDiv").hide();
\t $("#" + data_id).html(data);
\t \t });
}
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="lazy_content" data-url="/ajax/comments/aurum-didyma-spa-beach-resort" data-target-id="comments-content">
<h4>COMMENTS</h4>
<div id="comments-content" class="content-target"></div>
</div>
你有没有尝试http://jquery.eisbehr.de/lazy/? – Sami
我正在使用lazySizes插件,它不支持html的懒惰,我无法更改我的懒插件 –
请参阅准备使用示例:https://www.sitepoint.com/jquery-infinite-scrolling-demos/ 在这些页面中,您可以看到使用jQuery的示例(无插件) –