i have a global variable images, which is filled with path-names, coming from an xml file. The function that parses the xml-file works, and fills the array. But when the function is finished, my global variable is still empty. Does someone have a solution?
$(document).ready(function() {
var images = [];
var descriptions = [];
getImages();
function getImages() {
$(document).ready(function () {
$.ajax({
type: "GET",
url: "xml/page_pictures.xml",
dataType: "xml",
success: xmlParser
});
});
function xmlParser(xml) {
$(xml).find("pages").children().each(function() {
$(this).find("images").children().each(function() { //find all the image nodes in this node
images.push($(this).attr("path").toString());
descriptions.push($(this).find("image-label").text());
});
});
}
}
});
When debugging, i notice that at the end of the .each, my variable images is filled with 129 items, but when the function is completely finished and i check "images" after the getImages(), my variable "images" is empty again
Thanks in advance.