<div id="postswrapper">
<div class="item">content</div>
...
<div id="loadmoreajaxloader" style="display:none;"><center><img src="ajax-loader.gif" /></center></div>
</div>
<script type="text/javascript">
$(window).scroll(function()
{
if($(window).scrollTop() == $(document).height() - $(window).height())
{
$('div#loadmoreajaxloader').show();
$.ajax({
url: "loadmore.php",
success: function(html)
{
if(html)
{
$("#postswrapper").append(html);
$('div#loadmoreajaxloader').hide();
}else
{
$('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
}
}
});
}
});
</script>
Quote
The demo never reaches the end of content but if you included either a) logic in your backend script to return nothing when content finishes or; b) a loop for loading to reach the end, then you could achieve this quite easily.
var last_id = $('#mycontainer').last('.row').attr('id');
...
url: "loadmore.php?startID=" + last_id,
...
function loadData(pageLimit){
$('.flash').show();
$('.flash').fadeIn(100).html
('Loading');
var dataString = 'pageLimit='+ pageLimit;
$.ajax({
type: 'POST',
url: '".BASEDIR."infusions/aya_aye_panel/includes/load-aye-votes.php',
data: dataString,
cache: false,
success: function(result){
$('.flash').hide();
$('.load_more_link').addClass('noneLink');
$('#pageData').append(result);
}
});
}
loadData('0');
Quote
This is the script I have now. It uses pagelimit to show them 10 posts each then click more but when it gets to the end there is no data but it kaape trying to load it giving me multiple empty divs. lol
if (html.length > 1) {
//There is content, do stuff
} else {
//There is no more content
$('#mycontainer').addClass('no-more-content');
}
if (!$('#mycontainer').hasClass('no-more-content')) { //Continue, more content can pulled }
function loadData(pageLimit){
if (html.length > 1) {
$('.flash').show();
$('.flash').fadeIn(100).html
('Loading');
var dataString = 'pageLimit='+ pageLimit;
$.ajax({
type: 'POST',
url: '".BASEDIR."infusions/aye_panel/includes/load-more.php',
data: dataString,
cache: false,
success: function(result){
$('.flash').hide();
$('.load_more_link').addClass('noneLink');
$('#pageData').append(result);
}
});
} else {
//There is no more content
$('#pageData').addClass('no-more-content');
}
}
loadData('0');
function loadData(pageLimit) {
if (!$('#pageData').hasClass('no-more-content')) {
$('.flash').show();
$('.flash').fadeIn(100).html('Loading');
var dataString = 'pageLimit='+ pageLimit;
$.ajax({
type: 'POST',
url: '".BASEDIR."infusions/aye_panel/includes/load-more.php',
data: dataString,
cache: false,
success: function(html) {
if (html) { // try html.length > 1 if it doesn't work as expected
$('.flash').hide();
$('.load_more_link').addClass('noneLink');
$('#pageData').append(html);
} else {
$('#pageData').addClass('no-more-content');
}
}
});
}
}
function loadData(pageLimit) {
if (!$('#pageData').hasClass('no-more-content')) {
$('.flash').show();
$('.flash').fadeIn(100).html('Loading');
var dataString = 'pageLimit='+ pageLimit;
$.ajax({
type: 'POST',
url: '".BASEDIR."infusions/aye_panel/includes/load-more.php',
data: dataString,
cache: false,
success: function(html) {
if (html) { // try html.length > 1 if it doesn't work as expected
$('.flash').hide();
$('.load_more_link').addClass('noneLink');
$('#pageData').append(html);
} else {
$('.flash').hide();
$('#pageData').addClass('no-more-content');
}
}
});
}
}
$items_per_page = 25;
$result = dbquery("SELECT ..... LIMIT 0,$items_per_page");
if (dbrows($result)>0) {...... while ..... }
echo "<div id='Craig'></div>\n";
echo "<form>\n";
echo "<button id='Hien' value='25'>Load More</button>\n";
echo "</form>\n";
[code]
[code]
$('#Hien').bind('click', function() {
var RowStart = $(this).val(); // <---- we need this to send to Ajax File
$.ajax({
type: 'POST',
url: '".BASEDIR."infusions/aye_panel/includes/load-more.php',
data: { 'rowstart' : RowStart },
cache: false,
success: function(html) {
if (html) {
next_value = RowStart+".$items_per_page.";
$('#Hien').val(next_value); // there - it will become 50.. when you click, you send 50 to Ajax... and 75.. and so on.
$('#Craig').append(html);
} else {
$('#pageData').addClass('no-more-content');
}
}
});
});
$items_per_page = 25;
$result = dbquery("........... LIMIT $_POST['rowstart'], $items_per_page");
if (dbrows($result)>0) {.... loop result out } else { echo "No more content. Aye!"; }
Category Forum
Modifications and Requests - 8Labels
None yet
Statistics
4 participants
Notifications
You are not receiving notifications from this thread.
Related Questions