This function load data from db, how to execute it when user scroll page down and scroll top
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function(){
//var to auto-increment
var flag = 0;
$.ajax({
type: "GET",
url: "db_load.php",
data:{
'offset': 0,
'limit': 3
},
success: function(data){
$('body').append(data);
flag += 3;
}
});
}); //end document.ready function
</script>
I need a simple way to detect whenever user scroll down and scroll up and than call the function above