1

I'm trying to use spservices getlistitems to read a list on the root site. This is to populate the navigation for a custom master page so the navigation list just exists on the root site : i.e. http://mysp.sharepoint.com/

I'm able to call the list successfully from the root site, but if I go to a subsite (mysp.sharepoint.com/dept/hr ) the call does not work.

I tried specifying with the webUrl but it did not work either:

$().SPServices({
   webUrl: "https://mysp.sharepoint.com",
   operation: "GetListItems",
   async: false,
   listName: "navigation",
   CAMLViewFields: caml,  
   completefunc: function (xData, Status) {
     $(xData.responseXML).SPFilterNode("z:row").each(function() {
              var title = $(this).attr('ows_Title');

    });
   }
});

Any ideas on how I can call the list in a parent site?

  • For querying the root (mysp.sharepoint.com) you can simply pass '/' as webUrl, or use _spPageContextInfo. Check you console error logs for that particular call. It could be due the permission – Aveenav Oct 12 '16 at 21:40
2

You need to replace the webUrl with webURL in line 2. It will work fine. Refer the updated code below.

$().SPServices({
 webURL: "https://mysp.sharepoint.com",
 operation: "GetListItems",
 async: false,
 listName: "navigation",
 CAMLViewFields: caml,  
 completefunc: function (xData, Status) {
 $(xData.responseXML).SPFilterNode("z:row").each(function() {
          var title = $(this).attr('ows_Title');

 });
}
});
0

I passed in the list GUID and it worked - an explicit url or '/' for the webUrl property did not work.

$().SPServices({
  //    webUrl: "https://mysp.sharepoint.com",   //did not work
    operation: "GetListItems",
    async: false,
    listName: "{300cdf29-6f57-424c-99b2-8fad22453fge}",
    CAMLViewFields: caml,   
    completefunc: function (xData, Status) {
     $(xData.responseXML).SPFilterNode("z:row").each(function() {
              var title = $(this).attr('ows_Title');

     });
   }
 });
  • Put the updated code.. – Ronak Patel Oct 13 '16 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.