I am trying to get field values (field1 and field2)from the SharePoint list JQuery and Rest services to auto populate two other txt fields, but while the Title field is coming fine the other two field values are coming undefined. The below is the part of the code pulling the value:
function setFields(txtValue) {
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('ListName')/items?$filter=Title eq '" + txtValue + "'";
alert(requestUri);
// execute AJAX request
$.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data) {
var dataResults = data.d.results;
alert(dataResults[0].Title);
var firstField = dataResults[0].field1;
alert(firstField);
var secField = dataResults[0].field2;
},
error: function () {
alert("Failed to get details");
}
});
}