You have to return the value at the end of the ParseXML
function, not at the end of the success
function.
Controller.ParseXML = function (url) {
var itemList = null;
$.ajax({
type: "GET",
url: url,
dataType: "xml",
async: false,
success: function(xml) {
$(xml).find("event").each(function() {
var _id = $(this).attr("id");
var _eventItemDay = $(this).find("eventItemDay").text();
...
var _eventItemLocation = $(this).find("eventItemLocation").text();
itemList = {
id: _id,
eventItemDay: _eventItemDay,
eventItemLocation: _eventItemLocation,
...
eventItemLocation: _eventItemLocation
};
});
},
error: function(xhr, ajaxOptions, thrownError){
alert("XML ERROR");
alert(xhr.status);
alert(thrownError);
}
});
return itemList;
};