javascript - Scope issue of parameters in JS function
巴扎黑
巴扎黑 2017-06-26 10:52:31
0
1
650

1. I wrote a drop-down scroll bar to load more functions. The code is as follows. Thedroploadevent 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 inmethodandparam, 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?droploadIn the ajaxModel function body, shouldn’t its parameters be always valid for the internally executed function? Why areparamand 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) { //这里是具体操作 } }) } })
巴扎黑
巴扎黑

reply all (1)
迷茫

Look in success to see if there is any code to clear the param?

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!