adandy Posted August 6, 2014 Share Posted August 6, 2014 I am trying to implement lazy loading into a project with pagination already set up. If I was to go to my website and after the .com, type in "api_courselist.php?page=1" I would receive the first 20 results of my query. If I was to change that to page=2, it would retrieve the next 20 and so on. My issue is I have no idea how to implement that into my java script/ajax file. I have it set up so that when the user scrolls to the bottom of the page, a div will make its self visible with the new page populated inside of it and IT will keep on pulling pages in till There is no more content. jQuery(function ($) { jQuery(document).ready(function() { var is_loaded = true; jQuery(window).scroll(function() { if(jQuery(window).scrollTop() == jQuery(document).height() - jQuery(window).height()) { jQuery('div#loadMore').show(); if(is_loaded){ is_loaded = false; jQuery.ajax({ url: "api_courselist.php?page=1", success: function(html) { is_loaded = true; if(html){ jQuery("#infiscroll").append(html); jQuery('div#loadMore').hide(); }else{ jQuery('div#loadMore').replaceWith("<center><h1 style='color:red'>End of Content !!!!!!!</h1></center>"); } } }); } } }); }); }); Link to comment https://forums.phpfreaks.com/topic/290310-getting-my-ajax-to-pull-the-correct-page-results-for-lazy-loading/ Share on other sites More sharing options...
adandy Posted August 6, 2014 Author Share Posted August 6, 2014 Howe can I increase the page=1 by one every time the use hits the bottom of the page Link to comment https://forums.phpfreaks.com/topic/290310-getting-my-ajax-to-pull-the-correct-page-results-for-lazy-loading/#findComment-1487032 Share on other sites More sharing options...
Sean_Tublewicz Posted August 10, 2014 Share Posted August 10, 2014 Make a variable on page load and set value to 1. Each time a new page is pulled in increment the value by 1 and call the link with the variable... Or are you looking for actual code? Link to comment https://forums.phpfreaks.com/topic/290310-getting-my-ajax-to-pull-the-correct-page-results-for-lazy-loading/#findComment-1487294 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.