function UpdateList() { // Open the xml file $.get("locations.xml",{},function(xml){ // Run the function for each name tag in the XML file $('location',xml).each(function(i) { alert($(this).find("name").text()); }); alert("Test"); }); }
you just needed to put the last alert inside the $.get callback func