console.log(id);
打印一个函数,因此抛出TypeError。如果没有,那该怎么办?function xmlParser(xmlResponse) {
if (window.DOMParser) {
parser = new DOMParser();
console.log(xmlResponse);
xmlDoc = parser.parseFromString(xmlResponse, "text/xml");
console.log(xmlDoc);
}
id = xmlDoc.getElementsByTagName("id")[0].childNodes[0].nodeValue;
console.log(id);
key = xmlDoc.getElementsByTagName("passkey")[0].childNodes[0].nodeValue;
console.log(key);
return format(id, key);
}
答案 0 :(得分:0)
不,您不需要转换回复,因为您可以responseXML
属性直接获得xmlDoc
。
示例:
xmlDoc = xmlResponse.responseXML; // you'll probably need to change it because I don't know what is value of xmlResponse in your case
id = xmlDoc.getElementsByTagName("id")[0].childNodes[0].nodeValue;
//and so on...