gpt4 book ai didi

javascript - ajax 在没有更多数据时隐藏加载更多按钮

转载 作者:行者123 更新时间:2023-12-03 08:00:46 24 4
gpt4 key购买 nike

我已经使用 ajax 实现了加载更多功能在yii 。这就是我在 script 中所做的事情:

 $(document).ready(function() {
$(document).on('click', '.discover-more', function() {
$('.discover-more').hide();
$('.loading').show();
var lastId = $('ul#ulscroller li:last').attr('id');
$.ajax({
cache: false,
type: 'POST',
url: '<?php echo $host . $url . '/index.php?r=site/LoadMore&lastid=' ?>' + lastId,
success: function(data) {
$('#ulscroller').append(data);
$('.discover-more').show();
$('.loading').hide();
if (data.length() == 0) {
$('.discover-more').hide();
$('.nomore').show();
}


}


});
});
});

现在,我要做的就是在没有更多 images 时隐藏“发现更多”按钮以显示。我在 success 中尝试了几种方法回电,例如 if(data.length() == 0)if(data.size() < 1)但两者似乎都不起作用?有什么想法吗?

最佳答案

试试这个,

if($.trim(data).length == 0)

希望这会起作用!

关于javascript - ajax 在没有更多数据时隐藏加载更多按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34589875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com