有关JavaScript的问题,一直提示没有定义这是为什么?
主页:<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01//EN""http://www.w3.org/TR/html4/strict.dtd...
主页:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>9.1.3数据装载</title>
<script src="js/common.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript"> function loadXML(){
var majax =new MyAjax();
majax.sendData("GET","a.XML",true,rwrite);
}
function rwrite(xmlhttp)
{
var content=document.getElementById("content");
content.innerHTML="";
var ul=document.createElement("ul");
content.appendChild(ul);
var xmlDOM = xmlHttp.responseXML;
var root = xmlDOM.getElementsByTagName("root");
for(i=0;i<root.length;i++){
for(j=0;j<root[i].childNodes.length;j++){
if(root[i].childNodes[j].nodeType!=3){
var li=document.createElement("li");
var pchild=root[i].childNodes[j];
ul.appendChild(li);
li.innerHTML="姓名:"+pchild.getElementsByTagName("name")[0].firstChild.nodeValue;
li.innerHTML+="性别:"+pchild.getElementsByTagName("sex")[0].firstChild.nodeValue;
li.innerHTML+="年龄:"+pchild.getElementsByTagName("age")[0].firstChild.nodeValue;
li.innerHTML+="出生日期:"+pchild.getElementsByTagName("birth")[0].firstChild.nodeValue;
li.innerHTML+="出生地:"+pchild.getElementsByTagName("birthplace")[0].firstChild.nodeValue;
}
}
}
}
</script>
</head>
<body>
<label>
<input type="submit" name="button" id="button" value="装载XML文件" onclick="loadXML()" />
</label>
<div id="content"></div>
</body>
</html>
common.js内容
请问为什么一直提示MyAjax未定义了?应该定义了的啊! 展开
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>9.1.3数据装载</title>
<script src="js/common.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript"> function loadXML(){
var majax =new MyAjax();
majax.sendData("GET","a.XML",true,rwrite);
}
function rwrite(xmlhttp)
{
var content=document.getElementById("content");
content.innerHTML="";
var ul=document.createElement("ul");
content.appendChild(ul);
var xmlDOM = xmlHttp.responseXML;
var root = xmlDOM.getElementsByTagName("root");
for(i=0;i<root.length;i++){
for(j=0;j<root[i].childNodes.length;j++){
if(root[i].childNodes[j].nodeType!=3){
var li=document.createElement("li");
var pchild=root[i].childNodes[j];
ul.appendChild(li);
li.innerHTML="姓名:"+pchild.getElementsByTagName("name")[0].firstChild.nodeValue;
li.innerHTML+="性别:"+pchild.getElementsByTagName("sex")[0].firstChild.nodeValue;
li.innerHTML+="年龄:"+pchild.getElementsByTagName("age")[0].firstChild.nodeValue;
li.innerHTML+="出生日期:"+pchild.getElementsByTagName("birth")[0].firstChild.nodeValue;
li.innerHTML+="出生地:"+pchild.getElementsByTagName("birthplace")[0].firstChild.nodeValue;
}
}
}
}
</script>
</head>
<body>
<label>
<input type="submit" name="button" id="button" value="装载XML文件" onclick="loadXML()" />
</label>
<div id="content"></div>
</body>
</html>
common.js内容
请问为什么一直提示MyAjax未定义了?应该定义了的啊! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询