Given the following index.html
<!DOCTYPE html>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script>
var nodes = [];
$.get("mappings/Actor.hbm.xml", function(d){
nodes.push({"id":nodes.length,
"label":$(d).find("class").attr("table"),
"x":0,
"y":0
});
});
console.log(nodes)
</script>
And the following outtake of the xml
<hibernate-mapping>
<class name="nl.sander.mieras.localhost.sakila.Actor" table="actor" catalog="sakila">
The console shows an empty array [] when I put the console.log(nodes) outside the method body. It seems as if the push of data into the var nodes array is not persisted outside the scope of the method body.
How do I persist/store/save/hold (don't know the technical js term) the pushed data into the var nodes array, in order to be able to console.log(nodes) and see the object instead of an empty array?