script var Items adding document ready function ajax type GET url Item

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<script>
var Items;
//adding
$(document).ready(function() {
$.ajax({ type: "GET", url: "Item.xml", dataType: "xml", async: false, success: function (xml) {
Items= xml.getElementsByTagName("ITEM");
}
});
var Locations=[];
$.ajax({ type: "GET", url: "Location.xml", dataType: "xml", async: false, success: function (xml) {
Locations= xml.getElementsByTagName("Location");
}
});
$(".item").click(function() {
alert($(this).attr('id'));
alert(Items[0].innerHTML);
for(var i=0;i<Items.length;i++)
{
var child=Items[i].childNodes;
alert(child[0].value);
}
});
});
//
</script>
<div id="Settings">
<div id='TimeGUI'></div>
<div id='Game'><div class="item" id="U01" width="200px" height="300px">Test</div></div>
</div>