初学问题,请指教!
这是书上抄的第一个程序,可就是没结果,真郁闷。第一个程序都不行,请帮我看看
<script type="text/javascript">
var XmlHttp;
function CreateXmlHttpRequest(){
if(window.XMLHttpRequest)
{
XmlHttp=new XMLHttpRequest();
if (XmlHttp.overrideMiMeType)
{
XmlHttp.overrideMiMeType=('text/xml');
}
}
else if(window.ActiveXObject)
{
XmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
try{
XmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
}
catch (e)
{
try{
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{}
}
}
if (!XmlHttp)
{
alert('错误,放弃创建一个 XMLHTTP 实例!');
XmlHttp=false;
}
}
function StartRequest(){
CreateXmlHttpRequest();
alert("aaa");
XmlHttp.onreadystatechange=HandleStateChange;
XmlHttp.open("GET","innerhtml.xml",true);
XmlHttp.send(null);
}
function HandleStateChange(){
if(XmlHttp.readyState==4){
if(XmlHttp.status==200){
document.getElementById("results").innerHtml=XmlHttp.responseText;
}
}
}
</script>
<body>
<form>
<input type="button" value="Search for Today's Activioties" />
<div id="results">test</div>
</form>
</body>
</html>
innerhtml.xml
<?xml version="1.0" encoding="utf-8" ?>
<table border="1">
<tbody>
<tr>
<th>Activity Name</th>
<th>Location</th>
<th>Time</th>
</tr>
<tr>
<th>Waterskiing</th>
<th>Dock #1</th>
<th>9:00 am</th>
</tr>
<tr>
<th>Volleyball</th>
<th>East Court</th>
<th>2:00 am</th>
</tr>
<tr>
<th>Hiking</th>
<th>Trail 3</th>
<th>3:30</th>
</tr>
</tbody>
</table>
|