Programmer Question
What is the best to use global variables outside of a callback function?
var icon;
$(function(){
$.get('data.xml', function(xml){
icon = xml.documentElement.getElementsByTagName("icon");
//this outputs a value
console.log(icon);
});
//this is null
//How can this maintain the value set above?
console.log(icon);
});
Find the answer here
No comments:
Post a Comment