Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Get List Items using rest api

$
0
0

Hello,

<script type="text/javascript">
        var url = _spPageContextInfo.siteAbsoluteUrl;

        $(document).ready(function () {
            GetEvents();
        })

        function GetEvents() {
            var listname = $('#hdnlstThoughtOfTheDay').val();
            $.ajax({
                url: url + "/_api/web/lists/getbytitle('" + listname + "')/items?$expand=ContentType",
                type: "GET",
                headers: { "Accept": "application/json;odata=verbose" },
                success: function (data, textStatus, request) {
                    alert(data);
                    var dataResults = data.d.results;
                    alert(dataResults[0].Title);
                },
                error: function (msg) {
                    alert("error:" + JSON.stringify(msg));
                }
            });
        }
    </script>

I tried using above code but its not working.

Always getting data.d as 'undefined' as there is already items in list to show.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>