2013-03-25 60 views
0

我有当它的功能外,如果我然后将其放在我得到该行的作品一个XMLHttpRequest 94 Uncaught SyntaxError: Unexpected token var .意外标记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; 

} } 

回答

4

你忘了()

function readXML() { 
// Here --------^ 
+0

WTF!这样的小姐!谢谢。 – Dymond 2013-03-25 09:11:55

+2

@Dymond:大声笑嘿,我们都做到了。 ;-) – 2013-03-25 09:15:51

3

你缺少的()函数声明

function readXML() { 

    var xmlhttp; 
    ...