jQuery - scrolling loading. 
<p>I'm trying to make a sort of infinite scroll on my own. The reason i'm not using Infinite is because I'm not gonna use it in Wordpress.</p>

<p>It's working, except for that I need to use the on.() method, I just can't figure out how to do it. </p>

<pre><code>$(window).scroll(function(){
    if($(window).scrollTop() == $(document).height() - $(window).height()){
        $('.wait-please').show();
        latestTask();
    }
});

function latestTask()
{
    $id = $(".latestTask:last").attr("taskid");
    $.post("/includes/classes/handler.php?do=lastTask", { lastId : $id },
    function(data){
        if(data){
            //alert(data);
            $('.latestTask:last').after(data);
        }
        $('.wait-please').hide();
    });
}
</code></pre>

<p>The function latestTask calls a php script, where I'm echoing all the new posts. The problem is that it keeps calling the same ten because I need to on.() method to bind the new elements. </p>

<p>But where and how would I use On in this situation? For what I see I need to specify an event like click. But I dont have a click event?</p>

<p>The structure of the retrieved data is following:</p>

<pre><code>echo "&lt;div style='font-size:20px;color:#f90;' class='latestTask' taskid='$row[lookupId]'&gt;$row[lookupId]&lt;/div&gt;";
</code></pre>

<p><strong>UPDATE</strong></p>

<p>Here is the line of id's im getting when scrolling: </p>

<p>75
74
73
75
74
73
72
71
70
72
71
70
69
68
67
66
65
64
66
65
64
63
62
61
63
62
61
60
57
55
60
57
55
43
40
38
43
40
38
33
29
22
33
29
22</p>

<p>As you can see there's some very weird results from the database calls: 72, 71, 70, 72, 70. And it looks like I have to make it unable for the user to "double-scroll".. But how?</p>
