One of my functions involves making an ajax call and receiving data in the callback. It looks something like this:
function fetchData(callback) {
//perform ajax
if(callback) {
callback(data.data);
}
}
If I use the function like this:
fetchData(function(data) {
return data;
})
I am able to retrieve the necessary data. How can I transfer all the objects along with their key/value pairs to a
self.list = ko.observableArray([]);
so that I have access to the data throughout the code?