1
我敢肯定,這可能是我愚蠢的,但我想確認這個問題。我正在構建一個Windows 8應用程序,並從MySQL服務器加載數據,我似乎無法解決此問題。從一些閱讀中,我猜測問題是代碼在json請求之前執行是正確的,並且有辦法解決它。返回值在那裏,因爲它在一個返回數據並顯示它的函數中。 「SampleItems [0]」顯示完美,但JSON內部的東西不會,但控制檯日誌顯示它正在從服務器獲取數據。預先感謝任何幫助!JSON問題與執行
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;
謝謝你這麼做了一個夢! – jayhassett89