代码:
<html>
<head>
<title>prototypetest</title>
<script src="prototype.js"></script>
<script language="javascript">
function GetXmlContent()
{
var a = {idArea:"320110"};
var url = "2.xml";
var paras = $H(a);
var myAjax = new Ajax.Request(
url,
{
method:'get',
parameters:paras.toQueryString(),
onComplete:showMessage
});
}
function showMessage(response)
{
var xmlDOM = response.responseXML;
var root = xmlDOM.documentElement;
var area = root.getElementsByTagName("area");
for(i=0;i<area.length;i++)
{
var name = area[i].getElementsByTagName("name");
alert(name[0].firstChild.data);
var id = area[i].getElementsByTagName("id");
alert(id[0].firstChild.data);
}
}
</script>
</head>
<body>
<div id="xmlContent" onClick="GetXmlContent()">nihao</div>
</body>
</html>
感觉prototype.js比较不错,要多使用,还有,就是应该在理解了原理得基础上使用,会达到事半功倍得效果。
<html>
<head>
<title>prototypetest</title>
<script src="prototype.js"></script>
<script language="javascript">
function GetXmlContent()
{
var a = {idArea:"320110"};
var url = "2.xml";
var paras = $H(a);
var myAjax = new Ajax.Request(
url,
{
method:'get',
parameters:paras.toQueryString(),
onComplete:showMessage
});
}
function showMessage(response)
{
var xmlDOM = response.responseXML;
var root = xmlDOM.documentElement;
var area = root.getElementsByTagName("area");
for(i=0;i<area.length;i++)
{
var name = area[i].getElementsByTagName("name");
alert(name[0].firstChild.data);
var id = area[i].getElementsByTagName("id");
alert(id[0].firstChild.data);
}
}
</script>
</head>
<body>
<div id="xmlContent" onClick="GetXmlContent()">nihao</div>
</body>
</html>
感觉prototype.js比较不错,要多使用,还有,就是应该在理解了原理得基础上使用,会达到事半功倍得效果。