Error creating Infinite Scroll

0

I'm trying to create a% infinite% co, but when I run it I get a reference error in Scroll

  

jquery.js: 8706 GET link 404 (Not Found)

the code of my GET is:

<script type="text/javascript">
    $(window).scroll(function() { <-- linea donde me marca error
        if($(window).scrollTop() + $(window).height() >= $(document).height()) {
            var last_id = $(".post-id:last").attr("id");
            loadMoreData(last_id);
        }
    });

    function loadMoreData(last_id){
      $.ajax(
            {
                url: '/loadMoreData.php?last_id=' + last_id,
                type: "get",
                beforeSend: function()
                {
                    $('.ajax-load').show();
                }
            })
            .done(function(data)
            {
                $('.ajax-load').hide();
                $("#post-data").append(data);
            })
            .fail(function(jqXHR, ajaxOptions, thrownError)
            {
                  alert('server not responding...');
            });
    }
</script>

This is the code that I have in Script

$conexion = conexion($bd_config);

$qry = "SELECT * FROM publications WHERE id < $_GET['last_id'] ORDER BY id DESC LIMIT 8"; 
$result = $conexion->query($qry);

$json = include('views/empleos.php');

echo json_encode($json);

and this is my code where loadMoreData: is displayed:

<?php while ($post = $result -> fetch(PDO::FETCH_ASSOC)){ ?>

    <div class="box-list" id="post-data">
        <div class="item">
            <div class="row">
              <p class="post-id" id="<?php echo $post['id']; ?>">
                <div class="col-md-1 hidden-sm hidden-xs">
                    <div class="img-item"><img src="<?php echo OTRA; ?>/images/<?php echo $post['thumb']; ?>" alt=""></div>
                </div>
                <div class="col-md-11">
                    <h3 class="no-margin-top"><a href="single.php?id=<?php echo $post['id']; ?>"><?php echo $post['titulo']; ?> <i class="fa fa-link color-white-mute font-1x"></i></a></h3>
                    <h5><span class="color-black"><?php echo $post['company']; ?></span> - <span class="color-white-mute"><?php echo $post['locacion']; ?></span></h5>
                    <p class="text-truncate "><?php echo $post['extracto']; ?></p>
                    <div>
                    <span class="color-white-mute"><?php echo fecha($post['fecha']); ?></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php } ?>

but if you are bringing everything from the database, I do not know what happens, I just started using ajax

    
asked by Cesar Gutierrez Davalos 04.06.2017 в 10:40
source

0 answers