I am having trouble understanding something about execution order of code using JQuery. I have the following function attached to a button (it uses the :
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"); } What I expect to happen is that the alert will be displayed for each of the name tags in the XML file, and then finally the "Test" alert will be called. Instead, the "Test" alert appears first and then the tag alerts pop up. How should I be formatting this to ensure everything gets executed in the correct order? Thanks :)