XmlHttpRequestが関数の外側にあるときに機能します。次にそれを関数の内側に配置すると、行94に次のようになります。Uncaught SyntaxError: Unexpected token var .
私の行94はvar xmlhttp;
私はグーグルを持っていて、それが機能するはずの他の機能を見ていますか?
何か案は ?これは私が今持っているものです。
function run(){
readXml();
}
function readXML{
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.open("get", 'xml/stickers.xml', false);
xmlhttp.send();
var myXML = xmlhttp.responseXML;
stickers = myXML.getElementsByTagName("sticker");
for( i = 0; i<stickers.length; i++){
var idNod = (stickers[i].getElementsByTagName("id")[0].childNodes[0].nodeValue); /*Get the ID*/
var id = idNod;
var textNod = (stickers[i].getElementsByTagName("text")[0].childNodes[0].nodeValue); /* Text*/
add_sticker(textNod); /*Call creator function*/
var Xnod = (stickers[i].getElementsByTagName("x")[0].childNodes[0].nodeValue)+'px'; /*Get the x position Add PX for pixel*/
var Ynod = (stickers[i].getElementsByTagName("y")[0].childNodes[0].nodeValue)+'px'; /*Get the y position*/
var Znod = (stickers[i].getElementsByTagName("z")[0].childNodes[0].nodeValue); /*Get the y position*/
//console.log(Ynod)
//console.log(Xnod)
document.getElementById(id).style.top=Ynod; /* Style the position if the div. well done */
document.getElementById(id).style.left=Xnod;
document.getElementById(id).style.zIndex=Znod;
} }