Sharepoint SP Service to subsite

Hi all,

The following are my codes: It retrieves information from a site then displays in on my main page.

 function HillbillySlider3(sliderList,slideContentField,slideBackgroundImageField, slideTitle) {
  
            //query to retrieve all items
            var query = "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Number'></Value></Neq></Where><OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query>";
  
            //return fields for slide content and background picture
            var camlViewFields = "<ViewFields><FieldRef Name='"+slideTitle+"' /><FieldRef Name='"+slideContentField+"' /><FieldRef Name='"+slideBackgroundImageField+"' /></ViewFields>";
  
           $().SPServices({
                 operation: "GetListItems",
                 async: true,
                 listName: sliderList,
                 CAMLViewFields: camlViewFields,
                 CAMLQuery: query,
                 completefunc: function(xData, Status) {
                      $(xData.responseXML).SPFilterNode("z:row").each(function() {
                      var slideContent = ($(this).attr("ows_"+slideContentField));
                      var slideT = ($(this).attr("ows_"+slideTitle));
                      var Date = ($(this).attr("ows_"+slideBackgroundImageField));
                      Date = moment(Date).format('DD MMM');
                      
                    
                    
                      var res = slideT.split(", ");
                      $("#linksUL").append("<li><a href='" + res[0] + "' target='_blank'>" + res[1] + "</a></li>");                      
                   
                        


                 }); // end completefunc
                 //start the slider
                             }
           }); // end SPServices call
        }

How do I get retrieve it from a subsite???

Thanks in advance!

July 30th, 2015 2:53am

Try to add web URL,

 function HillbillySlider3(sliderList,slideContentField,slideBackgroundImageField, slideTitle) {
  
            //query to retrieve all items
            var query = "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Number'></Value></Neq></Where><OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query>";
  
            //return fields for slide content and background picture
            var camlViewFields = "<ViewFields><FieldRef Name='"+slideTitle+"' /><FieldRef Name='"+slideContentField+"' /><FieldRef Name='"+slideBackgroundImageField+"' /></ViewFields>";
  
           $().SPServices({

webURL: "/subsite1/subsite2/", 


                 operation: "GetListItems",
                 async: true,
                 listName: sliderList,
                 CAMLViewFields: camlViewFields,
                 CAMLQuery: query,
                 completefunc: function(xData, Status) {
                      $(xData.responseXML).SPFilterNode("z:row").each(function() {
                      var slideContent = ($(this).attr("ows_"+slideContentField));
                      var slideT = ($(this).attr("ows_"+slideTitle));
                      var Date = ($(this).attr("ows_"+slideBackgroundImageField));
                      Date = moment(Date).format('DD MMM');
                      
                    
                    
                      var res = slideT.split(", ");
                      $("#linksUL").append("<li><a href='" + res[0] + "' target='_blank'>" + res[1] + "</a></li>");                      
                   
                        


                 }); // end completefunc
                 //start the slider
                             }
           }); // end SPServices call
        }

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 3:08am

Thanks again! But I can't seem to mark this as answer.. weird...
July 30th, 2015 3:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics