I've been working with this code, which is originally from: Infinite Scroll Tutorial (though I updated the deprecated sql editted it a bunch)
The problem that I'm having is that the ajax isn't triggering/working. I put in the alert before the $.ajax
so that I would know when it triggered, and it's triggering when I hit the bottom of the page(or close to it), like it should. But the ajax isn't producing any information, and I'm not sure why.
emptyk.php:
<script src="../jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
$(window).scroll(function(){
$('#a1').text($(window).scrollTop());
$('#a2').text($(window).height());
$('#a3').text($(document).height());
});
var page = 1;
$(window).scroll(function(){
if($(window).scrollTop() + $(window).height() > $(document).height() - 500) {
page++;
var data = {
page_num: page
};
var actual_count = "<?php echo $actual_row_count; ?>";
if((page-1)* 10 > actual_count){
//$('#load').show();
}else{
alert("Ajax active");
$.ajax({
type: "POST",
url: "emptykdata.php",
data:data,
success: function(res) {
$("#result").append(res);
}
});
}
}
});
});
</script>
<div id="a1">Wut</div>
<div id="a2">Wut</div>
<div id="a3">Wut</div>
<div id="result"></div>
emptykdata.php
<?php
include '../includes/connect.php';
$requested_page = $_POST['page_num'];
$set_limit = (($requested_page - 1) * 10) . ",10";
$resultstmt = mysqli_prepare($connection, "SELECT * FROM products ORDER BY Mminppu ASC LIMIT $set_limit");
mysqli_stmt_execute($resultstmt);
$result = mysqli_stmt_get_result($resultstmt);
$add = mysqli_num_rows($result);
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
$_SESSION['PID'] = $row['PID'];
include '../includes/baseproductlist.php';
}
//echo $html;
?>
Any ideas?
Update:
I checked the javascript console, and it has the following error message:
GET http://localhost/Triiline2/jquery-1.10.2.min.map 404 (Not Found)