var Items adding document ready function ajax type GET url Item xml da

 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
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() {
var check = $(this).attr('id');
for(var i=0;i<Items.length;i++)
{
var id=Items[i].getElementsByTagName("ID")[0];
if(check==id.childNodes[0].nodeValue){
var icon=Items[i].getElementsByTagName("IMG")[0];
$(" #Interface").append("<img id="+id.childNodes[0].nodeValue+" "+icon.childNodes[0].nodeValue+">");/*Добавляем иконку с id*/
}
}
});
});
//