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

Can i use SPServices from any subsites and site collection

Mar 17, 2011 at 6:20 AM

Hi All,
      I have a site http://mysite/subsite/subsitechild.
I created a list in a subsite  and i tried using Spservices to view the list on subsitechild but no data was shown
So what i did is created a sample list  on subsitechild  and used SPService and i got some data returned.
Can SPservice work across sites i 'm sure it usses Web services.
Is there anything i need to add to the config e.g..
    operation: "GetListItems",
    async: false,
    listName: "Tasks" - Do inee to specify a path to the subsite list?
Thanks in Advance

Mar 17, 2011 at 10:50 AM

You should be able to move up and down sites in the same site collection quite easily. The trick is if you had to go to a different site collection as the webservices are tied to the site collection you are on. One of the arguments used is WebUrl and this can be used to esnure that you are pointing at the correct location of the list/library you are looking for.

Mar 17, 2011 at 12:57 PM

thanks for the reply guys.
marc i can't read your post:)

Thanks evilgenius for the reply.I taught as much that i should be able to move between sites
I tried using the WebUrl between sites but not getting any data back.
My scenario again I have a site http://mysite/subsite/subsitechild.
Created a list in subsite and then try to access the list in the subsitechild .
Tried using the WebURL option in the subsite. When in the subsite i can return some list data but when i reference the same thing in
subsitechild it doesn't work e.g using

Any ideas
Mar 17, 2011 at 4:19 PM
Edited Mar 18, 2011 at 3:48 AM

Sorry about the previous post; stuff I email in from my iPhone sometimes does that.

WebURL is the answer. Do you have the value in quotes? (You don't in your post.)

This should be in the docs. Let me know if it isn't clear and any suggestions you have to improve them.


Mar 18, 2011 at 3:20 AM

Hi Marc,
        As you can see below i have used  the WebURL with no luck.
 As i explained the source list was created at "/sites/SiteCollection/SubSite/" and then on  "/sites/SiteCollection/SubSite/SubsiteChild"
i have a js that has the SPservices in it that is at /sites/SiteCollection/SubSite/ so the refrence is :

 <script type="text/javascript" src="/sites/SiteCollection/Subsite/RetailMenu.js"></script

So that the JS can be store in one place.Hope i have done well :(
Any ideas

   WebURL: "/sites/SiteCollection/SubSite/",
   operation: "GetListItems",
    async: false,
    listName: "Menu",
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='SiteName' Ascending='True'/><Value  Type='Text'>" + sitename + "</Value></Eq></Where></Query>",
    //CAMLQuery: "<Query></Query>",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title'/><FieldRef Name='Link'/><FieldRef Name='LinkName'/><FieldRef Name='SiteName'/><FieldRef Name='Parent'/></ViewFields>",
    //CAMLViewFields: "<ViewFields></ViewFields>",

Mar 18, 2011 at 3:54 AM

Mea culpa. I was sending from my iPhone and  didn't actually look at the correct spelling of the option. It's webURL. Note the small 'w'.


   operation: "GetListItems",
   async: false,
   webURL: "/sites/SiteCollection/SubSite/",
listName: "Menu", ...


Mar 18, 2011 at 4:51 AM

Its not your mea culpa  but mine :)
I was pulling out my hair whereas i didn't notice the magic small "w".

Mar 18, 2011 at 9:10 AM

Just an FYI. If you cross post items to the STP forum check both locations for answers. I should have reposted my answer from there back here as well and for that I am sorry!