1

I have a list for links in my footer that I'm using REST to populate.

$.ajax({
    url: "/_api/web/lists/GetByTitle('FooterLinks')/items",
    type: "GET",
    headers: {
        "accept": "application/json;odata=verbose",
    },
    success: function (data) {
        $.each(data.d.results, function (index, item) {
            $('#FooterLinks-placeholder').append("<dl id='" + item.columnID + "'><dt>" + item.Title + "</dt></dl>");
        });
    },
    error: function (error) {
        //alert(JSON.stringify(error));
    }
});

I just created a new site collection under the root /eu/ that has a copy of the list so the links can be independent of the root. I'm trying to use the same javascript (because there will be more regional site collections) across all of them but am unsure how to get the current site collection in as a variable into my request to make it something like:

url: "/{sitecollection}/_api/web/lists/GetByTitle('FooterLinks')/items",
4

Use _spPageContextInfo.siteAbsoluteUrl for getting the site collection url. For more info, refer : http://blah.winsmarts.com/2013-2-_sppagecontextinfo_is_your_new_best_friend.aspx

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.