1. I wrote a drop-down scroll bar to load more functions. The code is as follows. The dropload
event is a function that monitors the scrolling of the wheel. When page A is entered for the first time, ajaxModel is triggered.
function, and pass in method
and param
, but when the data on this screen is displayed and the scroll wheel is pulled down to load the data, the method and param are invalid. why is that? dropload
In the ajaxModel function body, shouldn’t its parameters be always valid for the internally executed function? Why are param
and method empty?
The expression may be a bit confusing. Let’s briefly summarize: when entering ajaxModel for the first time, both method and param have values, and param is passed to the dropload method below, but when the wheel scrolls, the second dropload method is triggered. , param is empty.
function ajaxModel(method,param){
// 页数
var page = 0;
// 每页展示12个
var size = 12;
// dropload 滚轮事件,滚到底部时就触发
var dropload = $('.resultlist').dropload({
scrollArea : window,
loadDownFn : function(me) {
page++;
$.ajax({
type : 'POST',
url : basePath + method + '/'+page+'/'+size+'.do',
data : {"keyword":param},
dataType : 'json',
success : function(data) {
//这里是具体操作
}
})
}
})