I'm a js/jquery noob and have been struggling to get an anonymous function to work as a regular function. Could someone point out what I'm doing wrong?
Here's what's taken me a few hours:
var tracklist = new Array();
function stuffXML(xml) {
$(xml).find('track').each(function(){
var logo = $(this).find('logo').text();
var location = $(this).find('location').text();
var id = $(this).find('identifier').text();
var info = $(this).find('info').text();
var title = $(this).find('title').text();
var creator = $(this).find('creator').text();
tracklist.push(logo,location,id,info,title,creator);
});
console.log('mid' + tracklist); //works here
}
$(document).ready(function(){
$.ajax({
type: "GET",
url: "real.xml",
dataType: "xml",
success: stuffXML
});
console.log(tracklist); //but not here - empty array
});
I'm trying to parse the list (a bunch of images & text for a slideshow) into an array (successful there) and then have them available but my scope is clearly too confined. I can't see what I'm doing wrong tho...
Any help would be appreciated...