<html>
<head>
<title>parseXML.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=BIG5">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script language="javascript" type="text/javascript">
var xmlHttp;
var responseType ="";
function creatXmlHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsofe.XMLHTTP");
}
else if(window.XMLHttp){
xmlHttp = new XMLHttp();
}
}
function startXmlHttpRequest(requestType){
responseType = requestType;
creatXmlHttpRequest();
xmlHttp.open("get","parseXML.xml",true);
xmlHttp.onreadyStateChange = handleStateChange;
xmlHttp.send(null);
}
function handleStateChange(){
if(xmlHttp.readyState==4){
if(xmlHttp.state==200){
if(responseType =="north"){
northList();
}
if(responseType =="all"){
allList();
}
}
}
}
function northList(){
var xmlDoc = xmlHttp.responseXML;
var northNode = xmlDoc.getElementByTagName("north");
var northStates = northNode.ChildNodes;
outList(northStates);
}
function allList(){
var xmlDoc = xmlHttp.responseXML;
var allStates = xmlDoc.getElementByTagName("state");
outList(allStates);
}
function outList(states){
//one of States
var oneState = null;
for(var i=0; i<states.length; i++){
oneState = states.[i];//缺少标识符
string += "/n" + oneState.nodeValue;
}
alert(string);
}
</script>
</head>
<body>
<input type="button" value="northList" onclick="startXmlHttpRequest('north');">//缺少对象
<br/>
<input type="button" value="allList" onclick="startXmlHttpRequest('all');">//缺少对象
</body>
</html>
这是什么,语法不对啊,有了[]还要.干吗
把这里改掉,
缺少对象的问题自然就会好了,
另外还有,
怎么会让一个xml文件去处理ajax?
如果你改成form提交,你会把action写成一个xml文件吗?