私はそれを機能させるために一緒に接続する必要があるJSコードを持っています。私のjsコードは、データベースからフェッチされたより多くのコンテンツをロードします.今までは、ユーザーがリンクをクリックすると、より多くのコンテンツがロードされます.
今、ページが終わりに近づいたときに自動的に読み込まれるようにしたいと考えています。私のコード:
さらに機能を読み込む
function myFunction() {
$(window).scroll(function () {
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
$("load_more"); < ---- ** HOW DO I CALL THE LOAD FUNCTION ?**
}
});
$(function () {
$(document).on("click", ".load_more", function () {
var last_msg_id = $(this).attr("id");
var device =<? php echo $idevice; ?>;
if (last_msg_id != 'end') {
$.ajax({//Make the Ajax Request
type: "POST",
url: "index_more.php",
data: "lastmsg=" + last_msg_id + "&aa=" + device,
beforeSend: function () {
$('a.load_more').html('<img src="img/loading.gif" />');
},
success: function (html) {
$("#more").remove();
$("ol#updates").append(html);
}
});
}
return false;
});
});
だから、私の質問は、どのように $(window).scroll から "load_more" 関数を呼び出すのですか?
ありがとう!