Is it possible to return the value from a REST response back to the calling function?
In the code below returneddata is always undefined. In the GetMyData function I can see the REST response and pick off an element...in this case element 1. But, when I try to return the value for further processing it vanishes. The var returneddata is undefined.
Is there a way around this? I'm trying to make my REST calls more general.
Thanks.
function GetItems()
{
var returneddata=GetMyData();
}
GetMyData: function()
{
$.ajax({
url: oDataUrl,
type: "GET",
dataType: "json",
headers: ="accept": "application/json;odata=verbose",
success: function (data)
{
var mydata=data.d.results;
console.log("success");
console.log(data.d.results[1]);
console.log(mydata);
return mydata;
},
error: function (error) {
console.log('fail');
}
});
},