In general, whenever you see a callback function in JavaScript the code is run asynchronously and the same applies to the Crossrider API callbacks. In your example, the appAPI.request.get onSuccess callback is only called once the data is received, whilst the alert is called immediately after the request is fired and before the data is received.
The correct way to code this is to place the alert in the callback function so that it's called when the data is received. Using your code as an example, it should look something like:
appAPI.ready(function($) {
function get_wishlists() {
appAPI.request.get({
url: 'http://mysite.local/list/view/1?time=' + $.now(),
onSuccess: function(response, additionalInfo) {
myList = response;
alert(myList);
if (myList.indexOf('Your list:')) {
myList = myList.substr(myList.indexOf('Your list:') + 10);
myList = myList.split(',');
} else {
alert('Could not get list from your account, server response: ' + myList);
}
},
onFailure: function(httpCode) {
//alert('Error - Could not acquire a list of your wishlists. HTTP Code: ' + httpCode);
return null;
}
});
}
get_wishlists();
});
Additionally (and as an aside). note that your function get_wishlists is never actually called since when setting myList you are calling a different function get_list.
[Disclosure: I am a Crossrider employee]