I'm sure this is probably me being stupid but I want to confirm this issue. I am building a windows 8 app and loading in data from a mysql server and I can't seem to fix this issue. From a bit of reading I am guessing the issue is that the code is executing before the json request is this correct and is there a way to resolve it. The return is there because it is inside a function which returns the data and then displays it. The "SampleItems[0]" displays perfectly but the stuff inside the json wont but a console log shows it is getting data from the server. Thanks in advance for any help!
var sampleItems = [];
sampleItems[0] = { group: sampleGroups[count], title: "New Image", subtitle: "", description: "", content: "", backgroundImage: "/images/add.png" };
//this code calls to our cloud based service which gets the data which is needed and returns it in a JSON object back for this to handle
$.getJSON('http://pumpstationstudios.com/tumapics/services/getimages.php', function (data) {
var service_url = 'http://pumpstationstudios.com/tumapics/';
var count = 1;
images = data.items;
$.each(images, function (index, image) {
image.image = service_url + image.image;
sampleItems[count] = { group: sampleGroups[count], title: "Hello", subtitle: "", description: "", content: "", backgroundImage: image.image };
count++;
});
});
return sampleItems;