As first what I want, is when I scroll to the bottom of the page there will load 5 new posts from the database.
I'm doing a $.ajax()
call where I give;
- method: "POST"
- url: "gastenboek_load_posts.php"
- data: { 'rows': rows }
I did put an alert()
on every single place to check where is goes wrong, and commented lines out of what I was thinking that was wrong.
And I came by the part of data: { 'rows': rows }
How can it be that this gives an error that says;
TypeError: 'click' called on an object that does not implement interface HTMLElement.
http://code.jquery.com/jquery-latest.min.js
Line 4
This is the whole jQuery
code;
$(window).scroll(function() {
if ($(window).scrollTop() == $(document).height() - $(window).height())
{
var rows = $("#feedback_field").find(".gb_list_item");
$.ajax({
method: "POST",
url: "gastenboek_load_posts.php",
data: { 'rows': rows}
}).done(function(data){
$("#feedback_field").append(data);
});
}
});
Maybe the PHP response
code for if you need it what I think is not important for this problem;
<?
include_once 'core/init.php';
?>
<div id="feedback_field">
<ul>
<?
$a = 10;
if (load_next_5_gb_posts($a) == false)
{
echo 'Alle gegevens zijn geladen!';
}
else
{
$posts = load_next_5_gb_posts($a);
foreach ($posts as $data)
{
$a++;
}
?><input type="hidden" id="new_posts" value="<?=$a?>"><?
foreach ($posts as $posts)
{
?>
<li class="gb_list_item">
<div id="poster">
<p><?=$posts['naam']?></p>
<p><?=$posts['email']?></p>
<p>
<?
$datum = $posts['datum'];
$week_days_en = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
$week_days_nl = array("Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag");
$months_en = array("January", "February", "Mart", "April", "May", "June", "July", "Augustus", "September", "October", "November", "December");
$months_nl = array("Januari", "Februari", "Maart", "April", "Meiy", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December");
$date = date_create($datum);
echo str_replace($week_days_en, $week_days_nl, str_replace($months_en, $months_nl, date_format($date,"l d F Y")));
?>
</p>
</div>
<div id="msg">
<?=nl2br($posts['msg'])?>
</div>
</li>
<?
}
}
?>
</ul>
</div>