- 爱易网页
-
AJAX教程
- 帮忙看看改写的AJAX有什么东东没
日期:2014-05-16 浏览次数:20607 次
帮忙看看改写的AJAX有什么错误没?
之前用的html的FORM提交用sumbit的那种,现在改写为ajax,,貌似不对
</script>
</script>
<script type="text/javascript">
function loadXMLDoc()
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for Firefox, Mozilla, IE7, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET","iocontrol3.cgi",true);
xmlhttp.send(null);
setTimeout("loadXMLDoc()",1000);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = "OK"
str = xmlhttp.responseText;
canshu = str.split(";");
document.getElementById('port1').innerHTML=canshu;
document.getElementById('port2').innerHTML=canshu;
document.getElementById('port3').innerHTML=canshu;
}
else
{
alert("Problem retrieving data:" + xmlhttp.statusText);
}
}
}
}
</script>
</head>
<body>
<script type='text/javascript' language='JavaScript'>
//<!--#Form3-->
</script>
<form method="get" action="iocontrol3.cgi" name="iocontrol3">
<table border="1">
<b><font size="5"> Form3 Control</font>
<tr>
<td>PORT1<br>
<select name="port1" >
<option value="0">OFF
<option value="1">ON
</select>
</td>
<td>PORT2<br>
<select name="port2">
<option value="0">OFF
<option value="1">ON
</select>
</td>
<td>PORT3<br>
<select name="port3">
<option value="0">OFF
<option value="1">ON
</select>
</td>
<td><br>
<input type="button" onclick="loadXMLDoc()" name=WM value="submit">
</td>
</tr>
</table>
<br>
</form>
</body>
</html>