This project has moved and is read-only. For the latest updates, please go here.

Can't find items in List using "GetListItems"

Aug 18, 2015 at 8:15 PM
I can't seem to figure out why I'm not able to enumerate through the list items that I'm fetching through "GetListItems". There are items in the list. I see the response back in xData.responseText -> which is below:
"<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd=""><soap:Body><GetListItemsResponse xmlns=""><GetListItemsResult><listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
 <rs:data ItemCount="3">
 <z:row ows_Title='Slide 1' ows_MetaInfo='1;#' ows__ModerationStatus='0' ows__Level='1' ows_ID='1' ows_UniqueId='1;#{B9EB6F30-A049-41CB-A69D-B13C8092FB02}' ows_owshiddenversion='2' ows_FSObjType='1;#0' ows_Created='2015-08-18 13:00:04' ows_PermMask='0x7fffffffffffffff' ows_Modified='2015-08-18 13:01:54' ows_FileRef='1;#sites/msp/Lists/Feature Carousel/1_.000' />
 <z:row ows_Title='Slide 2' ows_MetaInfo='2;#' ows__ModerationStatus='0' ows__Level='1' ows_ID='2' ows_UniqueId='2;#{605D9FA5-B256-435F-81C4-60495CD45A18}' ows_owshiddenversion='2' ows_FSObjType='2;#0' ows_Created='2015-08-18 13:00:24' ows_PermMask='0x7fffffffffffffff' ows_Modified='2015-08-18 13:02:10' ows_FileRef='2;#sites/msp/Lists/Feature Carousel/2_.000' />
 <z:row ows_Title='Slide 3' ows_MetaInfo='3;#' ows__ModerationStatus='0' ows__Level='1' ows_ID='3' ows_UniqueId='3;#{52FFC8A9-4C1C-4BCF-AAA1-95CBD30E7CA9}' ows_owshiddenversion='1' ows_FSObjType='3;#0' ows_Created='2015-08-18 13:02:45' ows_PermMask='0x7fffffffffffffff' ows_Modified='2015-08-18 13:02:45' ows_FileRef='3;#sites/msp/Lists/Feature Carousel/3_.000' />
But when it doesn't go in the
$(xData.responseXML).SPFilterNode("z:row").each(function(e) { 
loop because it's length is "0"

I investigate the xData object and it doesn't find "responseXML" property.

Am I missing something? Any help is appreciated.

Below is the code:
var method = "GetListItems";
        var list = "Feature Carousel";
        var fieldsToRead = "<ViewFields>" +
                        "<FieldRef Name='Title' />" +                       
         var query = "<Query>" +
                            "<Where>" +
                                "<Neq>" +
                                    "<FieldRef Name='ID'/><Value Type='Number'>0</Value>" + 
                                "</Neq>" +
                            "</Where>" +                     
            operation: method,
            async: false,  
            listName: list,
            webURL : '/sites/msp/',
            CAMLViewFields: fieldsToRead,
            CAMLQuery: query,
            completefunc: function (xData, Status) { 

                    console.log(xData); //I SEE xData.responseText = WHICH IS THE XML ABOVE - SHOWS 3 ROWS 
                    console.log($(xData.responseXML).SPFilterNode("z:row").length);  //THIS IS "0"

                    $(xData.responseXML).SPFilterNode("z:row").each(function(e) { 

Aug 19, 2015 at 12:28 AM
Comparing to other pages, in another website - in the response, xData has "responseText".

Also, for some reason - SPservices is doing 2 calls:

XHR finished loading: POST "http://txdal11epwbts02:27869/_vti_bin/Webs.asmx"
XHR finished loading: POST "http://txdal11epwbts02:27869/sites/msp/_vti_bin/Lists.asmx"

Any help would be appreciated.
Aug 19, 2015 at 12:56 PM
In your CAML query, the field type is actually a "Counter" field type, rather than a "Number" field type. See if changing that works for you.
Aug 20, 2015 at 12:52 AM
I tried that and it didn't work.

The weird thing when I do a "console.log(xData);" - i see responseText = which has the xml string above. But there is no node called "xData.responseXML".
Aug 20, 2015 at 1:02 AM
So I have to do a parseXML and create that note manually = which doesn't sound right.
 completefunc: function (xData, Status) { 
                     xData.responseXML = $.parseXML(xData.responseText);
This works and is able to loop and fetch the items. But I'm still confused why.
Aug 23, 2015 at 8:08 PM

You shouldn't have to do that conversion. I don't see anything obvious in what you've posted. jQuery should be handing you the xData object with the responseXML object as well.

What version of SharePoint and SPServices are you on?

Aug 24, 2015 at 5:41 PM
I'm using Version 2014.02, jQuery is v1.9.1

Yes, but for some odd reason - the responseXML doesn't exist. So for now I'm wrapping it inside an if statement - because I need to make it work asap:
      xData.responseXML = $.parseXML(xData.responseText);
I'm also wondering why it's making 2 calls:


This is a top level site in its own web application - note the port.

In my Spservices options, I have to specifiy the "webURL" or else it returns a 404 on the .asmx:
 webURL : '/sites/msp/',
These are the things I found odd. I've used SPSErvices for many sites - this is the only one that's giving me problems.
Aug 29, 2015 at 1:53 PM
In your code, CAMLViewFields is only requesting the "Title" field. Therefore, only the "Title" field will be accessible in the responseXML "loop". Trying to read other fields will cause the code to fail. To test this theory, change the CAMLViewFields variable from ' "<ViewFields>" +"<FieldRef Name='Title' />" + "</ViewFields>"' to
'<ViewFields Properties="True"/>', which is a shortcut approach for retrieving data for all of the list columns.
Aug 31, 2015 at 10:07 PM
Edited Aug 31, 2015 at 10:08 PM
Thanks for the suggestion b52radarnav - but in my actual query it has more than just the title:
var fieldsToRead = "<ViewFields>" +
                        "<FieldRef Name='Title' />" + //Committee
                        "<FieldRef Name='Content'/>" + //Amount
                        "<FieldRef Name='Image' />" + //Group by
                        "<FieldRef Name='Category'/>" +
                        "<FieldRef Name='Video_x0020_Url'/>" + 
                        "<FieldRef Name='Allow_x0020_hide' />" + 
                        "<FieldRef Name='Order0' />" + 
         var query = "<Query>" +
                            "<Where>" +
                                "<Neq>" +
                                    "<FieldRef Name='ID'/><Value Type='Number'>0</Value>" + 
                                "</Neq>" +
                            "</Where>" +
                            "<OrderBy>" + 
                                "<FieldRef Name='Order0' Ascending='TRUE'/>" +
                            "</OrderBy>" +
And as far as looping through the "responseXML" without the necessary fields - I am not even able to do a loop because it's undefined. That's why I have to do a weird assignment - which I'm not even supposed to be doing per Marc.

The weird thing is - I have response from "responseText" property (which is the xml string). This means that the call was successful and produced results. So the CAML is good. It just doesn't parse to that "responseXML" property so I can loop.
Sep 1, 2015 at 2:39 AM
I still don't get why you aren't seeing responseXML. That object should be passed back to you by the AJAX call.

Try slimming down your call to only request the Title and see if responseXML is there. Then add column by column until you get back to where you want to be. That might help you figure out what's going on. In other words, do the most basic call you can, and then build back up.

Sep 1, 2015 at 12:03 PM
I remember this problem being reported once before (by Matt B., I think) for which I don't think we found a solution (other than to process the responseText).
The responseXML I believe is added by jQuery based on the response type (XML) or the type option given to .ajax().

-- sent from mobile