Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 滚动时将jquery变量增加1_Javascript_Jquery - Fatal编程技术网

Javascript 滚动时将jquery变量增加1

Javascript 滚动时将jquery变量增加1,javascript,jquery,Javascript,Jquery,每次滚动时,我都会遇到将变量增加1的问题。我成功地将变量增加了1,但只增加了一次。这是我得到的密码。我需要增加变量页 $(document).ready(function () { $(document).scroll(function (e) { currentPage = 0; if ($(window).scrollTop() >= $(document).height() - $(windo

每次滚动时,我都会遇到将变量增加1的问题。我成功地将变量增加了1,但只增加了一次。这是我得到的密码。我需要增加变量页

 $(document).ready(function () {
            $(document).scroll(function (e) {
                 currentPage = 0;
                if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
                    ++currentPage;
                    $.getJSON("../campus/Settings/TranslationSettings.ashx?command=show&page=" + currentPage + "&Lang=en", function (data) {
                        var items = [];
                        $.each(data.Keys, function (key, val) {

                            $("<ul/>", {
                                "class": "translateinfo",
                                html: "<li class='keystring'><span class='label'>text string:</span>" + val["text string"] + "</li>" + "<li class='autotranslate'><span class='label'>Automated translation:</span>" + val["automated translation"] + "</li>" + "<li class='functionnumber'><span class='label'>Function Number:</span>" + val["function number"] + "</li>" + "<li class='translateurl'><span class='label'>URL:</span>" + val["url"] + "</li>"
                            }).appendTo("#updatepanel");
                        });


                    });
                }
            });
        }); 
$(文档).ready(函数(){
$(文档)。滚动(功能(e){
currentPage=0;
if($(窗口).scrollTop()>=$(文档).height()-$(窗口).height()-10){
++当前页面;
$.getJSON(“../campus/Settings/TranslationSettings.ashx?command=show&page=“+currentPage+”&Lang=en”,函数(数据){
var项目=[];
$.each(data.Keys,function(key,val){
$(“
    ”{ “类”:“translateinfo”, html:
  • 文本字符串:“+val[“text string”]+”
  • “+”
  • 自动翻译:“+val[“Automated translate”]+”
  • “+”
  • 函数号:“+val[“Function Number”]+”
  • URL:“+val[“URL”]+”
  • ” }).附录(“更新面板”); }); }); } }); });
不确定是否复制/粘贴了整个代码。但每次用户滚动时,您都在重新创建currentPage

使用小提琴,我在滚动循环之前创建变量

var currentPage = 0;

        $(document).scroll(function (e) {
            if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
                ++currentPage;
                console.log(currentPage);
            }
        })