I'm trying to run an Ajax fetch which is apparently successful. What I'm unable to figure out is how to pull the individual field data to separate and use. I can display it all with a data.d.results alert, but what I'd like to do is change my alert to display just one field (i.e. just the email associated with the "extraPOC" field). Any help is much appreciated. I feel like this should be an easy one, but I've looked all over and can't quite get there. The closest I seem to get is to display the alert "object Object".
function findEmail(){
$.ajax({
url: _xpPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('myList')/items?$select=POC/EMail,extraPOC/EMail&$expand=POC,extraPOC&$filter=(ID eq '342')",
method: "GET",
headers: { Accept: "application/json;odata=verbose"},
success: function (data, headers){
if (data.d.results.length > 0){
alert (JSON.stringify(data.d.results));
}
},
error: function(error){
alert("Error: "+ JSON.stringify(error));
}
});
}
Result from alert("Error: "+ JSON.stringify(error)); :
[{"__metadata":{"id":"Web/Lists(guid'blah)Items(342)","uri":"https://.. blah blah list information... "type":"SP.Data.myListListItem"},"POC":{"results":[{"__metadata":{"id":"f1c17bda-234-233f-23sff3-sdfw3dfs0","type":"SP.Data.UserInfoItem"},"EMail":"test@email.now"}]},"extraPOC":{"results":[{"__metadata":{"id":"324-234a-2343de-13bf38deea","type":"SP.Data.UserInfoItem"},"EMail":"anothertest@email.now"}]}}}]
alert(JSON.stringify(data.d.results))
? – Dylan Cristy Jul 3 '18 at 14:39