I'm trying to get all values from a list and print it to screen.
I have a column named 'tz' and I want to print it only.
I use this code, but I am getting an error:
Unable to get property '0' of undefined or null reference"
<script>
$.ajax({
var siteurl = _spPageContextInfo.webAbsoluteUrl;
$.ajax({
url: siteurl + "/_api/web/lists/getbytitle('Projects')/items",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
if (data.d.results.length > 0 ) {
for (i = 0; i < data.d.results.length; i++)
{
alert(data.d.results[i].tz);
}
}
},
error: function (data) {
alert("Error: "+ data);
}
});
});
alerttoconsole.logand inspect it in F12 Dev console.... unless you really want to spend hours a day clicking OK in alert boxes