Answer the question
In order to leave comments, you need to log in
How to return an object from a function?
I can't figure out what my mistake is, return immediately returns an empty object.
function manipulate_slides_array(array, url) {
var objectData;
var objectResponse = $.post(
url,
{
slidesArray: array,
},
function (data, status) {
var isString = true;
try {
objectData = JSON.parse(data);
} catch (e) {
isString = false;
}
if (isString == false) {
M.toast({
html: data,
});
}
// console.log("Data: " + data + " " + status);
}
);
objectResponse.done(() => {
console.log("data from server --- ", objectData);
return objectData;
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question