Advertisement
Guest User

Untitled

a guest
May 31st, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     $(document).ready(function(){
  3.         var inProcess = false;
  4.         var num = 15;
  5.  
  6.         $(window).scroll(function() {
  7.             if($(window).scrollTop() + $(window).height() >= $(document).height() && !inProcess) {
  8.  
  9.                 $.ajax({
  10.                     url: 'http://pricel.od.ua/lazy',
  11.                     method: 'GET',
  12.                     data: {"num" : num},
  13.                     beforeSend: function() {
  14.                         inProcess = true;
  15.                     }
  16.                 }).done(function(data){
  17.                     data = JSON.stringify(data);
  18.                     data = jQuery.parseJSON(data);
  19.  
  20.                     if (data.length > 0) {
  21.                         $.each(data, function(index, data){
  22.                             $("#posts").append("<a href='http://pricel.od.ua/"+ data.category +"/"+ data.slug +"'><strong>" + data.id + "</strong>. " + data.name + "</p></a>");
  23.                         });
  24.  
  25.                         inProcess = false;
  26.                         num += 15;
  27.                     }
  28.                 });
  29.  
  30.             }
  31.         });
  32.     });
  33. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement