AJAX调用相同的函数不返回超过50条记录

时间:2016-07-27 19:10:36

标签: javascript jquery ajax

提前感谢您的任何反馈!

我需要调用相同的函数来加载数组。我使用50的分页大小来检索信息。尽管如此,它只返回前50个,而没有别的。

//CALLING FUNCTION
vm.audit.load(null, null, null, null, dateTime, null, null, 1, 50, null, null, 1000, null);

//FUNCTION
  o.load = function (applicationID, auditTypeID, auditUser, ipAddress, startDate, endDate, auditDescription, pageOffset, pageSize, orderBy, orderByDirection, pageMax, vthat) {
    var that;
    if (pageOffset === 1) {
        that = this;
    } else {
        that = vthat;
    }
    //var that = this;
    var dateTime = new Date();
    var def = $.Deferred();
   // def.async = true;
    that._isLoading = true;

    //var pageOffset = 1
    var vDel = false;

        audit.da.auditItems_get(applicationID, auditTypeID, auditUser, ipAddress, startDate, endDate, auditDescription, pageOffset, pageSize, orderBy, orderByDirection).done(function (eResult) {
            var items = eResult.d.auditItems;
            vCount = eResult.d.totalCount;
            that.set("tCount", vCount);

            if (pageOffset === 1)
            {
                vDel = true;
                if (vCount < pageMax) {
                    pageMax = vCount;
                }
            } else {
                vDel = false;
            }
            that.addArray(items, null, vDel);


            pageOffset += pageSize;
            if (pageOffset < pageMax) o.load(applicationID, auditTypeID, auditUser, ipAddress, startDate, endDate, auditDescription, pageOffset, pageSize, orderBy, orderByDirection, pageMax, that);

            def.resolve(that);
        }).fail(function (error) {
            if (init.onerror) init.onerror({ source: that, sourceType: that._name, error: error });
            def.resolve(that);
        }).always(function () {
            that._isloading = false;
            //if (init.onloading) init.onloading({ source: that, sourceType: that._name, isLoading: false });
        });


    return def.promise();
};

1 个答案:

答案 0 :(得分:0)

你有pageSize参数(第九个参数),我假设它是在函数调用中设置为50的返回记录数。将其更改为所需的记录数。