Im trying to build an windows8 app, i use the SplitApp as basic. Just trying to add data from AJAX but it fails.
In the file data.js i have:
(function () {
var list = new WinJS.Binding.List();
$.each(data(), function (key, item) {
list.push(item);
});
}
})();
In the file app.js i have (This works and populates the list in the app)
function data() {
var testGroupMeeting = [];
var testMeeting = [];
testGroupMeeting.push(new Group({ id: "1", title: "Group1" }));
testMeeting.push(new Meeting({ group: testGroupMeeting[0], title: "Item Title: 1" }));
return testMeeting;
}
But when i want to use AJAX to get data and return testMeeting when it is populated it crashes.
In the file app.js i have (Doesnt work) but i need to get this to work
function data() {
var testGroupMeeting = [];
var testMeeting = [];
$.ajax({
url: "/json/json.php",
dataType: 'json',
contentType: 'text/json',
type: 'GET',
success: function (data) {
//Data here is correct and mapped to the arrays, its the same as in the abow example, i have the same data in the arrays as in the above example
}
return testMeeting;
}
});
}
But the problem seems to be that AJAX is not supposed to be returning anything. And i cant do a callback to data.js because that function is anonymous as you can see.
How would you do this?