Reputation: 11
I've a calculated column(return data type: date and time) in SharePoint 2013 list, am trying to retrieve value and display in a form. I'm using the below function to get the value from SharePoint list:
function getData(g_Data_URL) {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + g_Data_URL,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function(data) {
var Onsite= new Date(data.d.Onsite);
$('#Ontime').data("DateTimePicker").date(Onsite);
},
error: function(error) {
console.log(JSON.stringify(error));
}
});
}
Please let me know if the syntax of calling the value is incorrect.
Any help is appreciated
Upvotes: 1
Views: 815
Reputation: 3655
From your code, your calculated column name is "Onsite". And I did a test on my end, it works well to get the value:
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ct3')/items(1)",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function(data) {
var Onsite= new Date(data.d.Onsite);
console.log(Onsite);
},
error: function(error) {
console.log(JSON.stringify(error));
}
});
Upvotes: 0