Javascript Js分页错误

Javascript Js分页错误,javascript,ajax,Javascript,Ajax,我需要执行分页,每次需要显示5行。显示前5行。在第二次单击时,单击下一个5行、第三行第11-15行,依此类推。我需要显示,即使在n次单击后至少有一行,其中totalRows mod 5小于5。我不明白 function rightArrow() { pageCount = document.getElementById('pgCnt').value; //totalRows / 5 totCount = document.getElementById('to

我需要执行分页,每次需要显示5行。显示前5行。在第二次单击时,单击下一个5行、第三行第11-15行,依此类推。我需要显示,即使在n次单击后至少有一行,其中totalRows mod 5小于5。我不明白

function rightArrow()
{   
        pageCount = document.getElementById('pgCnt').value; //totalRows / 5
        totCount = document.getElementById('totCnt').value; //totalRows
        currPage = tempRows - pageCount + 2; //current set of rows
        document.getElementById('tempPage').value = tempPage;
        var m = totCount%5;

        if(pageCount != tempRows)
            m = 5;
        else
        {   m = (totCount % 5) - 1; 
            document.getElementById('rightArr').disabled = true; 
        }

        document.getElementById('pgCnt').value = document.getElementById('pgCnt').value - 1;

        for(i = 0; i < m;i++)
        {
            $.ajax({    
                type: "POST",
                url: "getEODRow.php",
                data: "page=" + currPage + "&row=" + i,
                success: function(html)
                {
                    var row = document.getElementById('chRecommend').insertRow(0);
                    temp = html.split(",");
                    for(j = 0; j < 9; j++)
                    {
                        str = temp[j].replace("\"","");
                        str = temp[j].replace("\"",'');
                        str = temp[j].replace("[",'');
                        col = row.insertCell(j);
                        col.innerHTML = str;
                    }
                }
            });
        }
        currPage++;
}

我意识到这个问题已经死了,但我在寻找其他问题时遇到了它,我想我会抛出一个答案。因为这不是一个关键问题,所以我继续修改了这里的所有内容,以及许多您没有选择包含的代码

//应用程序名称空间 var MyApp={Paging:{}}; //寻呼控制器 MyApp.Paging.Controller=函数{this.init.applythis,arguments;}; MyApp.Paging.Controller.prototype= { //初始化器将所有内容连接起来 init:函数 { $.login正在初始化分页控制器。 //获取我们需要的所有节点 this.totCntNode=document.getElementByIdtotCnt; this.pgCntNode=document.getElementByIdpgCnt; this.currminode=document.getElementByIdcurrMin; this.currMaxNode=document.getElementByIdcurrMax; this.prevPageButton=document.getElementByIdprevPageButton; this.nextPageButton=document.getElementByIdnextPageButton; this.pageContainer=document.getElementByIdpageOfItems; //模拟表的.insertRow,使行添加更容易 this.pageContainer.insertRow=函数{ var row=document.createElementdiv; row.className=行clearfix; 对于var i=0;i0 { this.pageContainer.removeChildthis.pageContainer.children[0]; } //为新页面数据添加空间 对于变量rowInd=0;rowInd=总页数 { 如果此.nextPageButton.className.indexOfdisabled<0 { this.nextPageButton.className+=已禁用; } } //如果存在n,则启用“下一页”按钮 外部页面 其他的 { 如果此.nextPageButton.className.indexOfdisabled>-1 { this.nextPageButton.className=this.nextPageButton.className.replace/?:^ |\s+已禁用?!\s/g; } } }, //单击“下一页”按钮时会调用此选项。 显示下一页:功能 { 如果MyApp.Paging.Model.currentPage+1>=MyApp.Paging.Model.GetTotalPage { //无论如何都不应该激活这个 } 其他的 { MyApp.Paging.Model.currentPage++; 这是updatePageInfo; } 返回false; }, //单击“上一页”按钮时会调用此选项 showPrevPage:函数 {
如果MyApp.Paging.Model.currentPage我意识到这个问题已经死了,但我在寻找其他问题时遇到了它,我想我会抛出一个答案。因为这不是一个关键问题,我继续修改了这里的所有内容,加上许多您没有选择包含的代码

//应用程序名称空间 var MyApp={Paging:{}}; //寻呼控制器 MyApp.Paging.Controller=函数{this.init.applythis,arguments;}; MyApp.Paging.Controller.prototype= { //初始化器将所有内容连接起来 init:函数 { $.login正在初始化分页控制器。 //获取我们需要的所有节点 this.totCntNode=document.getElementByIdtotCnt; this.pgCntNode=document.getElementByIdpgCnt; this.currminode=document.getElementByIdcurrMin; this.currMaxNode=document.getElementByIdcurrMax; this.prevPageButton=document.getElementByIdprevPageButton; this.nextPageButton=document.getElementByIdnextPageButton; this.pageContainer=document.getElementByIdpageOfItems; //模拟表的.insertRow,使行添加更容易 this.pageContainer.insertRow=函数{ var row=document.createElementdiv; row.className=行clearfix; 对于var i=0;i0 { this.pageContainer.removeChildthis.pageContainer.children[0]; } //为新页面数据添加空间 对于变量rowInd=0;rowInd=总页数 { 如果此.nextPageButton.className.indexOfdisabled<0 { this.nextPageButton.className+=已禁用; } } //如果有下一页,请启用下一页按钮 其他的 { 如果此.nextPageButton.className.indexOfdisabled>-1 { this.nextPageButton.className=this.nextPageButton.className.replace/?:^ |\s+已禁用?!\s/g; } } }, //单击“下一页”按钮时会调用此选项。 显示下一页:功能 { 如果MyApp.Paging.Model.currentPage+1>=MyApp.Paging.Model.GetTotalPage { //无论如何都不应该激活这个 } 其他的 { MyApp.Paging.Model.currentPage++; 这是updatePageInfo; } 返回false; }, //单击“上一页”按钮时会调用此选项 showPrevPage:函数 {
如果MyApp.Paging.Model.currentPage使用模数来确定是否需要开始一个新行,即i%5A一句话的建议:习惯于使用var仔细声明所有局部变量…@ineedhelp-这里还有一件事需要考虑。我不知道获取错误行数的原因是什么,但请注意,不能保证AJAX响应将按照发出请求的顺序返回。因此,即使您获得了正确的行数,它们也很可能以不正确的顺序结束。无论如何,您最好一次获取5行。但是如果有46行,我需要分别打印第46行,然后只发送整页呢一次,最后一页前5行,最后一页上1-5行。使用模数确定是否需要开始新的一行,即i%5A建议:习惯于使用var仔细声明所有局部变量…@ineedhelp-这里还有一件事需要考虑。我不知道获取错误行数的原因,但请注意无法保证AJAX响应将按照发出请求的顺序返回。因此,即使您获得了正确的行数,它们也很可能以错误的顺序结束。无论如何,您最好一次获取5行。但是如果有46行,我需要打印第46行,该怎么办aratelyThen一次只发回整页,因此最后一页前5行,最后一页上1-5行。