jquery infinite scroll

JavaScript
$(window).scroll(function () {
    // End of the document reached?
    if ($(document).height() - $(this).height() == $(this).scrollTop()) {
        $.ajax({
            type: "POST",
            url: "index.aspx/GetData",
            contentType: "application/json; charset=utf-8",
            data: '',
            dataType: "json",
            success: function (msg) {
                if (msg.d) {
                    $(".container").append(msg.d);
                }
            },
            error: function (req, status, error) {
                alert("Error try again");
            }
        });
    }
}); 

Source

Also in JavaScript: