我使用3种不同的函数将数据加载到我的DIV中.我正在尝试阻止多个AJAX调用,当浏览器滚动条保持在我懒惰加载数据的DIV底部时.
这有效但有时(有时候)滚动器仍然在我的div的底部,这将导致许多AJAX调用发生.我该如何防止这种情况发生?
$(document).ready(function() {
//form submit by click
$("#submit").click(function(e) {
// Prevent Default Action In Case to Load data by form
e.preventDefault();
//prevent select to post empty data
$('select').each(function() {
if ($(this).val() == '') {
$(this).attr('disabled', 'disabled');
}
});
// Define what we need
var loading = "<img src='/zojfa/images/loading.gif' alt='Loading...' />";
var scrolltop = $('#scrollbox').attr('scrollTop');
var scrollheight = $('#scrollbox').attr('scrollHeight');
var windowheight = $('#scrollbox').attr('clientHeight');
var post = $(this).attr("name") + "=" + $(this).val();
var form_data = $('#search_form').serialize() + "&" + post;
var …Run Code Online (Sandbox Code Playgroud)