How to get pagination working? ListItemCollectionPositionNext not working? XML null error

Dec 5, 2014 at 7:38 PM
I'm trying to setup some pagination using this function to get the next position for a page search
function getNextPos(pos, rowLimit, camlQuery) {
    try {
        pos = pos.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
    }
    catch(e) {
    }

    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: list,
        CAMLQuery: camlQuery,
        CAMLQueryOptions: "<QueryOptions><Paging ListItemCollectionPositionNext='" + pos + "' /></QueryOptions>",
        CAMLRowLimit: rowLimit,
        completefunc: function (xData, Status) {
            pos = $(xData.response.XML).SPFilterNode("rs:data").attr("ListItemCollectionPositionNext");
        }
    });

    return pos;
}
I keep getting an "Error: Unable to get property 'XML' of undefined or null reference" when it tries to process the completefunc. It seems that the initial position is a null value, hence the error, but how do you initialize the pos value if you are starting from the beginning of the record set?

Thanks.
Dec 5, 2014 at 7:40 PM
sorry, jQuery 1.7.2, and SPServices 0.7.2
Coordinator
Dec 5, 2014 at 7:43 PM
You're ridiculously behind with those versions. Can you try the latest?

M.
Dec 8, 2014 at 1:24 PM
I would be happy to, but unfortunately, I am supposedly limited by my IT department. I'll see what I can do, but if I don't have any luck, is there anything I can do, besides updating my versions?

Thank You
Coordinator
Dec 8, 2014 at 2:53 PM
Well, it's hard to know if I've fixed some issue along the way already that addresses this. I'd suggest looking at the response coming back in Fiddler or Firebug to see what it contains.

M.
Dec 8, 2014 at 3:34 PM
Edited Dec 8, 2014 at 3:35 PM
OK, I'm probably going to get in trouble for doing it, but I snuck jquery-1.11.1.min.js and jquery.SPServices-20914.0.1.min.js in. I'm still getting the same error. Any thoughts?

Thanks
Dec 8, 2014 at 3:37 PM
Just read your reply @8:53 AM. Should I still try JSFiddle or Firebug?

Thanks
Dec 8, 2014 at 3:40 PM
Oops, sorry, just realized Fiddler is NOT JSFiddle. I'm really sure I can't get that by IT. Any other options?
Coordinator
Dec 8, 2014 at 3:44 PM
Wait, I just realized you have an error in your code.
pos = $(xData.response.XML).
should be
pos = $(xData.responseXML).
M.
Marked as answer by trout0525 on 12/9/2014 at 4:41 AM
Dec 9, 2014 at 12:40 PM
Hello Marc,

Thanks, I think that did it, yet I don't appear to be getting my results showing up, so I can page through them, but I think that's an error in my JavaScript coding.

Thanks for the help. How does one support you and your work?

Thank You
Dec 9, 2014 at 12:42 PM
Just so you know, I've got a totally different section to display my results. I just need the bit above to get the sections working.
Coordinator
Dec 9, 2014 at 2:16 PM
Glad that worked! There's a donate button on the home page, if you're so inclined. I'm also available for consulting projects. ;+)

M.