Hopefully I've just made a dumb oversight, but I can't figure out why the following doesn't work:
$(function() {
var xml;
$.get(
"somexml.xml",
function(data){
xml = data;
},
"xml");
alert(xml);
});
If I put the alert inside of the callback function, I get back object XMLdocument
but if I place it outside of the ajax call, I get undefined
.
Since my goal is to have a new DOM to parse, I don't want the entire handling of the XMLdocument to be within the callback function.
I've tried defining the variable outside of the entire onready function, inside at the top (like above) and inside the callback function, all with no luck.
According to Specifying the Data Type for Ajax Requests in the jquery documentation, this should be possible.