Thursday, April 28, 2016

Get an item value from a list using an ajax call


$.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/lists/getbytitle('SampleList')/items?$filter=Title eq '" + XYZ + "'",
    type: "GET",
    async: false,
    headers: { "Accept": "application/json;odata=verbose" },
    success: function (data) {
        for (var i = 0; i < data.d.results.length; i++) {
            var item = data.d.results[i];
            value = item.CustomColumn;
        }
    },
    failure: function () {
        console.log("Unable to get value", "error");
    }
});

No comments:

Post a Comment