Good afternoon, implemented a lazy load tape, which as the scrolling page loads the news. Used samopisny engine on Codeigniter 3.
Everything works, the problem is that$("#posts").append('');
You need to insert a large layout design in conjunction with the php functions of Codeigniter itself.
For example, the data array contains the date of the news in the unix_timestamp format .. I try to display it using the native Codeignter function:
$.each(data, function(index, data){ $("#posts").append('<?php unix_to_human( + data.created + )?>'); }); This output does not work. How can append such a complicated output using php tags in append?
PS I give the full code below:
<script type="text/javascript"> $(document).ready(function(){ var inProcess = false; var num = 15; $(window).scroll(function() { if($(window).scrollTop() + $(window).height() >= $(document).height() && !inProcess) { $.ajax({ url: 'http://домен/lazy/index', method: 'GET', data: {"num" : num}, beforeSend: function() { inProcess = true; } }).done(function(data){ data = JSON.stringify(data); data = jQuery.parseJSON(data); if (data.length > 0) { $.each(data, function(index, data){ $("#posts").append(''); // вывод контента тут }); inProcess = false; num += 15; } }); } }); });